> ## Documentation Index
> Fetch the complete documentation index at: https://docs.geode.ag/llms.txt
> Use this file to discover all available pages before exploring further.

# GeodeTypes.sol

> All shared structs, constants, and EIP-712 typehashes used across the Geode protocol.

## Overview

`GeodeTypes.sol` defines all shared data structures, protocol constants, and EIP-712 typehashes. All structs are declared at file level for ergonomic imports across the codebase.

## EIP-712 Constants

```solidity theme={null}
// Intent typehash — includes poolId for cross-pool replay protection
bytes32 constant INTENT_TYPEHASH = keccak256(
    "GeodeIntent(bytes32 poolId,address owner,address tokenIn,address tokenOut,"
    "uint256 amountIn,uint256 minAmountOut,uint256 deadline,uint256 nonce)"
);

// Permit2 witness — fields NOT already in PermitTransferFrom
bytes32 constant GEODE_WITNESS_TYPEHASH = keccak256(
    "GeodeWitness(bytes32 poolId,address tokenOut,uint256 minAmountOut)"
);

// Full witness type string appended to PermitWitnessTransferFrom
string constant WITNESS_TYPE_STRING =
    "GeodeWitness witness)GeodeWitness(bytes32 poolId,address tokenOut,"
    "uint256 minAmountOut)TokenPermissions(address token,uint256 amount)";

// Domain separator
bytes32 constant DOMAIN_TYPEHASH = keccak256(
    "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
);
string constant DOMAIN_NAME = "GeodeHook";
string constant DOMAIN_VERSION = "1";
```

## Protocol Constants

| Constant                               | Value      | Description                                     |
| -------------------------------------- | ---------- | ----------------------------------------------- |
| `Q128`                                 | `1 << 128` | Fixed-point multiplier for price representation |
| `ABSOLUTE_MAX_BATCH_SIZE`              | 256        | Hard ceiling on intents per side                |
| `DEFAULT_BATCH_INTERVAL`               | 1 block    | Minimum blocks between settlements              |
| `DEFAULT_DIRECT_SWAP_FEE_BPS`          | 30 (0.3%)  | Fee on direct swaps (curve pools; split 3 ways) |
| `DEFAULT_SETTLEMENT_FEE_BPS`           | 10 (0.1%)  | Fee per filled intent input                     |
| `DEFAULT_GAS_REIMBURSEMENT_MULTIPLIER` | 150 (1.5×) | Gas cost multiplier                             |
| `DEFAULT_MAX_GAS_REIMBURSEMENT`        | 0.01 ETH   | Cap per batch                                   |
| `BPS_DENOMINATOR`                      | 10,000     | Basis points divisor                            |

## Structs

### GeodeIntent

A user's signed trade intent:

```solidity theme={null}
struct GeodeIntent {
    PoolId poolId;        // Cross-pool replay protection
    address owner;        // Intent signer
    address tokenIn;      // Token being sold
    address tokenOut;     // Token being received
    uint256 amountIn;     // Amount to sell
    uint256 minAmountOut; // Minimum acceptable output (slippage protection)
    uint256 deadline;     // Expiry timestamp
    uint256 nonce;        // Permit2 replay protection
}
```

### BatchState

Per-pool batch state — overwritten each settlement cycle:

```solidity theme={null}
struct BatchState {
    uint256 blockNumber;
    uint256 totalBuyVolume;
    uint256 totalSellVolume;
    uint256 buyIntentCount;
    uint256 sellIntentCount;
    bool settled;
}
```

### SettlementResult

Output of the clearing price computation:

```solidity theme={null}
struct SettlementResult {
    uint256 clearingPrice;          // Uniform price in Q128
    uint256 internalMatch0;         // currency0 crossing internally → sellers
    uint256 internalMatch1;         // currency1 crossing internally → buyers
    uint256 residualSwapAmount;     // Amount to route through AMM/curve
    bool residualZeroForOne;        // Swap direction
    uint256 buyFees;                // Settlement fees from buy inputs (currency0)
    uint256 sellFees;               // Settlement fees from sell inputs (currency1)
    uint256 ammCounterfactualPrice; // AMM spot price for savings UI
    // Curve-mode fields (zero in standard mode):
    uint256 curveDispensed;         // Tokens dispensed from hook reserve
    uint256 curveAbsorbed;          // Tokens absorbed back into hook
    uint256 deployerRoyalty;        // Deployer's surplus share
}
```

### PoolConfig

Per-pool configuration — set once via `geodeInitializePool`:

```solidity theme={null}
struct PoolConfig {
    uint256 batchInterval;
    uint24 directSwapFeeBps;          // 0.3% for curve pools (3-way split)
    uint256 settlementFeeBps;
    uint256 maxBatchSize;
    uint256 maxGasReimbursement;
    uint256 gasReimbursementMultiplier;
    // Curve-pool fields (zero for standard pools):
    address deployer;
    uint24 deployerRoyaltyBps;
    uint256 virtualTokenReserve;
    uint256 virtualEthReserve;
}
```

### LaunchState

Per-pool permanent curve state:

```solidity theme={null}
struct LaunchState {
    uint256 cumulativeSupplyDistributed; // Tokens sold from hook reserve
    uint256 totalSupply;                 // Total supply of the launch token
    uint256 virtualTokenReserve;         // Cached Vt
    uint256 virtualEthReserve;           // Cached Ve
    uint256 ethReserve;                  // ETH from curve sales
    uint256 curveSupply;                 // Max dispensable tokens
    address tokenAddress;                // ERC20 address (non-zero = curve token)
    LaunchPhase phase;                   // Current lifecycle phase
}
```

### LaunchPhase

```solidity theme={null}
enum LaunchPhase {
    None,   // Standard Geode pool (not a curve)
    Active  // Permanent bonding curve — dual-path trading (direct + intent)
}
```

<Note>
  The `LaunchPhase` enum has only two values. The curve is permanent — there is no `PendingGraduation` or `Graduated` phase. Once `Active`, the curve operates forever.
</Note>

## Source

<Card title="GeodeTypes.sol" icon="github" href="https://github.com/Geode-vAMM/geodex/blob/main/contracts/src/libraries/GeodeTypes.sol">
  View the full source code on GitHub (\~157 lines).
</Card>
