CrocQuery Contract
The CrocQuery
contract provides a set of convenient view functions for querying the state of pool parameters, liquidity curves, tick boundaries, user LP positions, and user surplus collateral positions within the core CrocSwapDex
contract.
The CrocQuery
contract can be found at
Mainnet: 0xCA00926b6190c2C59336E73F02569c356d7B6b56
Scroll: 0x62223e90605845Cf5CC6DAE6E0de4CDA130d6DDf
Pool Price
The below functions are used to query the pool's instantenous price and prick tick respectively.
The parameter types are as follows:
base
- The address of the base-side token in the pool's pair (always the smaller address)quote
- The address of the quote-side token in the pool's pairpoolIdx
- The pool type index. (Defaults to 420 for standard pools)
Return value is the current price of the pool, where price is represented as a Q64.64 fixed point representation of the square-root of the current base to quote exchange rate in the pool.
The parameter types are as follows:
base
- The address of the base-side token in the pool's pair (always the smaller address)quote
- The address of the quote-side token in the pool's pairpoolIdx
- The pool type index. (Defaults to 420 for standard pools)
Return value is the current price tick of the pool, where tick is defined as the floor of the base 1.0001 logarithm of the pool price.
Pool Liquidity
The queryLiquidity
function returns the liquidity in a pool at its current tick. This can be used to estimate a price impact for small swaps, assuming they don't cross a tick boundary.
The parameter types are as follows:
base
- The address of the base-side token in the pool's pair (always the smaller address)quote
- The address of the quote-side token in the pool's pairpoolIdx
- The pool type index. (Defaults to 420 for standard pools)
Return value is the current liquidity in the pool, where liquidity is represented as the square-root of the full-range equivalent of the product of the base and quote virtual liquidity in the pool.
Ambient Liquidity Positions
The below function returns information associated with a full range ambient liquidity position
The parameter types are as follows:
owner
- The address of the position's ownerbase
- The address of the base-side token in the pool's pair (always the smaller address)quote
- The address of the quote-side token in the pool's pairpoolIdx
- The pool type index. (Defaults to 420 for standard pools)
Return values are as follows:
liq
- The full range liquidity contribution of this position as the square root of the base and quote tokensbaseQty
- The total amount of base side tokens currently owned by this positionquoteQty
The total amount of quote side tokens currently owned by this position
Range Liquidity Positions
The below function returns information associated with a concrentrated range liquidity position
The parameter types are as follows:
owner
- The address of the position's ownerbase
- The address of the base-side token in the pool's pair (always the smaller address)quote
- The address of the quote-side token in the pool's pairpoolIdx
- The pool type index. (Defaults to 420 for standard pools)lowerTick
- The tick index of the lower boundary of the range positionupperTick
- The tick index of the upper boundary of the range position
Return values are as follows:
liq
- The in-range liquidity contribution of this position as the square root of the virtual base and quote tokensbaseQty
- The total amount of base side tokens currently owned by this positionquoteQty
The total amount of quote side tokens currently owned by this position
Range Liquidity Positions
The below function returns information associated with a knockout liquidity or limit order position
The parameter types are as follows:
owner
- The address of the position's ownerbase
- The address of the base-side token in the pool's pair (always the smaller address)quote
- The address of the quote-side token in the pool's pairpoolIdx
- The pool type index. (Defaults to 420 for standard pools)pivot
- The EVM tick of when the limit order tick was created (used to distinguish knockout orders created at different times)isBid
- If true, indicates the this was a limit order swapping base tokens for quote tokens. Vice versa if otherwiselowerTick
- The tick index of the lower boundary of the range positionupperTick
- The tick index of the upper boundary of the range position
Return values are as follows:
liq
- The in-range liquidity contribution of this position as the square root of the virtual base and quote tokensbaseQty
- The total amount of base side tokens currently owned by this positionquoteQty
The total amount of quote side tokens currently owned by this positionknockedOut
- If true, indicates that the order has been atomically knocked out and the position is locked and no longer active on the liquidity curve.
Last updated