Skip to main content

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.

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_BPS20 (0.2%)Fee on non-intent swaps (standard pools; launch pools default to 100 / 1%)
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
    // Launch-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;
    uint256 settlementFeeBps;
    uint256 maxBatchSize;
    uint256 maxGasReimbursement;
    uint256 gasReimbursementMultiplier;
    // Curve-pool fields (zero for standard pools):
    address deployer;
    uint24 deployerRoyaltyBps;
    uint256 virtualTokenReserve;
    uint256 virtualEthReserve;
    uint24 maxResidualDeviationBps;
}

LaunchState

Per-pool launch curve state:
struct LaunchState {
    uint256 cumulativeSupplyDistributed;
    uint256 totalSupply;
    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 = launched)
    uint256 graduationEthThreshold;
    LaunchPhase phase;
}

LaunchPhase

enum LaunchPhase {
    None,              // Standard Geode pool (not a launch)
    Active,            // Curve trading active, direct swaps blocked
    PendingGraduation, // Thresholds met, awaiting finalization
    Graduated          // AMM live, curve disabled
}

Source

GeodeTypes.sol

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