mento-protocol / reserve-site

Mento Reserve Website
https://reserve.mento.org
1 stars 3 forks source link

Update reserve page to include collateral assets held in new UniswapV3 pools #27

Closed bayological closed 1 year ago

bayological commented 1 year ago

Description

As part of the v2 development 3 new pools with reserve-owned collateral will be created on UniV3. We need to update the reserve homepage to track these assets.

The total assets owned by the reserve can be calculated by doing the following:

Calculate share of pool for each position 1) Get the information for a position by calling the positions function from the NonfungiblePositionManager using the tokenId of the position 2) Get the pool for the position by first getting the factory contract from the position manager then executing the getPool function passing in the tokens in the position and the fee 3) Calculate the share of the pool by dividing the liquidity of the position by the total liquidity of the pool. Liquidity of the pool can be retrieved from the pool contract in the previous step by calling liquidity() 4) Fetch the pool reserves by using IERC20 balance of for each position token passing in the address of the pool as an argument 5) Calculate the token amounts by multiplying the pool share calculated by the reserves we previously fetched

Previous PR: https://github.com/mento-protocol/reserve-site/pull/21

Acceptance Criteria

~🚧 The calculation required to determine the reserve collateral assets in a Uni V3 pool is different. This needs to be figured out before this story can be started 🚧~

bayological commented 1 year ago

Story Points: 3 See the discussion in Sprint Poker #​​9

Powered by Parabol

ole-nov commented 1 year ago

FYI, UniV3 doesn't have LP tokens in a traditional sense. There are NFTs instead. So calculation probably will be different. We have couple of such NFTs from other pools in our MS wallet that you can use as an example: 0x655133d8E90F8190ed5c1F0f3710F602800C0150 @philbow61

bayological commented 1 year ago

@ole-nov Thank you