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 ​
Name | Type | Description |
---|---|---|
id_ | uint256 | Identifier for the operation type: 1 for swap, 2 for internal arbitrage |
swap0to1_ | bool | Direction of the swap: true if swapping token0 for token1, false otherwise |
token0_ | address | Address of the first token in the pair |
token1_ | address | Address of the second token in the pair |
price_ | uint256 | The price ratio of token1 to token0, expressed with 27 decimal places |
Return Values ​
Name | Type | Description |
---|---|---|
isOk_ | bool | Boolean 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 ​
Name | Type | Description |
---|---|---|
price | uint256 | The current price ratio of token1 to token0, expressed with 27 decimal places |