Skip to main content

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

// 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

ConstantValueDescription
Q1281 << 128Fixed-point multiplier for price representation
ABSOLUTE_MAX_BATCH_SIZE256Hard ceiling on intents per side
DEFAULT_BATCH_INTERVAL1 blockMinimum blocks between settlements
DEFAULT_DIRECT_SWAP_FEE_BPS30 (0.3%)Fee on direct swaps (curve pools; split 3 ways)
DEFAULT_SETTLEMENT_FEE_BPS10 (0.1%)Fee per filled intent input
DEFAULT_GAS_REIMBURSEMENT_MULTIPLIER150 (1.5×)Gas cost multiplier
DEFAULT_MAX_GAS_REIMBURSEMENT0.01 ETHCap per batch
BPS_DENOMINATOR10,000Basis points divisor

Structs

GeodeIntent

A user’s signed trade intent:
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:
struct BatchState {
    uint256 blockNumber;
    uint256 totalBuyVolume;
    uint256 totalSellVolume;
    uint256 buyIntentCount;
    uint256 sellIntentCount;
    bool settled;
}

SettlementResult

Output of the clearing price computation:
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:
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:
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

enum LaunchPhase {
    None,   // Standard Geode pool (not a curve)
    Active  // Permanent bonding curve — dual-path trading (direct + intent)
}
The LaunchPhase enum has only two values. The curve is permanent — there is no PendingGraduation or Graduated phase. Once Active, the curve operates forever.

Source

GeodeTypes.sol

View the full source code on GitHub (~157 lines).