I'm trying to get pool position parameters, like:
- liquidity
- feeGrowthInside0LastX128
- feeGrowthInside1LastX128
- tokensOwed0
- tokensOwed1
by polling positions() method in pool smart contract (I'm using Sushi V3 Pool). But I always get all zeroes!
Here is response example:
[ positions(bytes32) method Response ]
liquidity uint128 : 0
feeGrowthInside0LastX128 uint256 : 0
feeGrowthInside1LastX128 uint256 : 0
tokensOwed0 uint128 : 0
tokensOwed1 uint128 : 0
According to interface IUniswapV3PoolState {}, The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper. But how I can make this key?
What I tried:
- Get address (my wallet address or NFT Position Manager address), convert it to bytes
- Convert to bytes tick lower and tick upper using BigEndian or LittleEndian
- Concatenate bytes: 20 bytes of address + 3 bytes of tick lower + 3 bytes of tick upper = 26 bytes total
- Then I tried to either left pad this key to 32 bytes, or right pad to 32 bytes
In general, I tried all the options, but I always get only zeros!
Here is real live (though out of range) position you can use for investigation. This is DAI/USDT position in Sushi V3 Pool in Scroll network.
- NFT ID: 17959
- Tick Lower: -276333
- Tick Upper: -276317
- Check in pool: https://www.sushi.com/scroll/pool/v3/0x3aF6e93Ab55A78A5Ed01Db6c3bE3Af332b5abd3f/17959
- Interact with Pool smart contract: https://scrollscan.com/address/0x3aF6e93Ab55A78A5Ed01Db6c3bE3Af332b5abd3f#readContract
- Interact with NFT Position Manager contract: https://scrollscan.com/address/0x0389879e0156033202C44BF784ac18fC02edeE4f#readContract
PS. I can more easy get the same position information from NFT Position Manager (it also has positions() method which accepts NFT ID as a parameter), but I really need to interact with positions() method from Pool smart contract.