Getting data from pools
How to determine which token is token0 and which is token1?
How to get address of liquidity pool?
/// @inheritdoc IAlgebraFactory
mapping(address tokenA => mapping(address tokenB => address pool)) public poolByPair;/// @inheritdoc IAlgebraFactory
function computePoolAddress(address token0, address token1) public view returns (address pool);function computePoolAddress(address token0, address token1) public view returns (address pool) {
pool = address(uint160(uint256(keccak256(abi.encodePacked(hex'ff', poolDeployer, keccak256(abi.encode(token0, token1)), POOL_INIT_CODE_HASH)))));
}Custom Pools
1. Use customPoolByPair mapping in AlgebraFactory
2. Use computeCustomPoolAddress function in AlgebraFactory
3. Calculate custom pool address using create2 mechanism
Price
How to get current price in pool?
Can i use "price" value in pool as real price?
How to get actual execution price for swap?
Last updated