Skip to main content
This page matches shield_swap.aleo at source commit b66d4f2.

Market state

PoolState

token0: field, token1: field, fee: u16, enabled: bool. Token identifiers are sorted. The AMM stores and calculates all token amounts in each token program’s native base units. The current struct has no decimal scale fields.

Slot

tick: i32, tick_spacing: u32, sqrt_price: u256::U256, fee_protocol: u8, liquidity: u128, fee_growth_global0_x_128: u256::U256, fee_growth_global1_x_128: u256::U256, max_liquidity_per_tick: u128, protocol_fees0: u128, protocol_fees1: u128, next_init_below: i32, next_init_above: i32.

Tick

pool: field, liquidity_net: i128, liquidity_gross: u128, tick: i32, fee_growth_outside0_x_128: u256::U256, fee_growth_outside1_x_128: u256::U256, prev: i32, next: i32.

Position

token_id: field, pool: field, tick_lower: i32, tick_upper: i32, liquidity: u128, fee_growth_inside0_last_x_128: u256::U256, fee_growth_inside1_last_x_128: u256::U256, tokens_owed0: u128, tokens_owed1: u128.

Keys and identifiers

PoolKey

token0: field, token1: field, fee: u16.

PairKey

token0: field, token1: field. It omits the fee so one pair pause spans all fee tiers.

TickKey

pool: field, tick: i32.

SwapKey

pool: field, zero_for_one: bool, amount_in: u128, sqrt_price_limit: u256::U256, recipient: address, nonce: u64, caller: address.

TokenIDPreimage

request: MintPositionRequest, recipient: address, nonce: field.

ChecksumEdition

checksum: [u8; 32], edition: u16. The upgrade constructor hashes this value into a multisig operation ID.

MerkleProof

siblings: [field; 16], leaf_index: u32. The AMM accepts two proofs for each non-inclusion check and permits a maximum effective tree depth of 15.

Requests and outputs

MintPositionRequest

pool: field, tick_lower: i32, tick_upper: i32, amount0_desired: u128, amount1_desired: u128, amount0_min: u128, amount1_min: u128, tick_lower_hint: i32, tick_upper_hint: i32.

SwapRequest

pool: field, zero_for_one: bool, amount_in: u128, amount_out_min: u128, sqrt_price_limit: u256::U256, recipient: address, nonce: u64, deadline: u32. The deadline is an Aleo block height.

SwapHop

pool: field, zero_for_one: bool, sqrt_price_limit: u256::U256.

SwapMultiHopRequest

token_in: field, token_out: field, amount_in: u128, amount_out_min: u128, recipient: address, hop0: SwapHop, hop1: SwapHop, hop2: SwapHop, hop_count: u8, nonce: u64, deadline: u32, caller: address. The current finalizer accepts only two or three active hops.

SwapOutput

recipient: address, caller: address, token_in: field, token_out: field, amount_out: u128, amount_remaining: u128. Single-hop and multi-hop swaps use this same shape. A multi-hop output refunds only unspent original route input. It does not store one refund slot per hop.

Swap-loop helpers

SwapIterCfg

z: bool, lim: u256::U256, fee_pips: u32, fee_protocol: u8, slot_fg0: u256::U256, slot_fg1: u256::U256.

SwapIterState

sp: u256::U256, rem: u128, out: u128, fg: u256::U256, liq: u128, tk: i32, crossed: bool, pf: u128, nb: i32, na: i32. u256::U256 contains hi: u128 and lo: u128. Fee growth and square-root prices both use this wide type, but they have different semantic units.