Skip to content

IHook ​

dexPrice ​

solidity
function dexPrice(uint256 id_, bool swap0to1_, address token0_, address token1_, uint256 price_) external returns (bool isOk_)

Hook function to check for liquidation opportunities before external swaps

The primary use of this hook is to check if a particular pair vault has liquidation available. If liquidation is available, it gives priority to the liquidation process before allowing external swaps. In most cases, this hook will not be set.

Parameters ​

NameTypeDescription
id_uint256Identifier for the operation type: 1 for swap, 2 for internal arbitrage
swap0to1_boolDirection of the swap: true if swapping token0 for token1, false otherwise
token0_addressAddress of the first token in the pair
token1_addressAddress of the second token in the pair
price_uint256The price ratio of token1 to token0, expressed with 27 decimal places

Return Values ​

NameTypeDescription
isOk_boolBoolean indicating whether the operation should proceed

ICenterPrice ​

centerPrice ​

solidity
function centerPrice() external returns (uint256 price)

Retrieves the center price for the pool

This function is marked as non-constant (potentially state-changing) to allow flexibility in price fetching mechanisms. While typically used as a read-only operation, this design permits write operations if needed for certain token pairs (e.g., fetching up-to-date exchange rates that may require state changes).

Return Values ​

NameTypeDescription
priceuint256The current price ratio of token1 to token0, expressed with 27 decimal places