position-manager.ts
File Missing
The complete file is missing for arbitrum-one
path: /src/mappings/position-manager.ts
getPosition()
Params:
- event (ethereum.Event): An event from the NFT Position Manager contract
- tokenId (BigInt): NFT Id for the staked position
ReturnType: Position | null
- Eth Mainnet
- Polygon, Optimism
- Returns a
Positionentity for the giventokenIdif found. - If not found, retrieves a position by directly querying the
NonfungiblePositionManagercontract using the ABI. InvokesfactoryContract.getPool()and passing it theposition's parameterstoken0,token1andfeeto find thepoolcontract address. - Then creates a new position entity for the tokenId and set the metadata properties using
positionread earlier from theNonfungiblePositionManagercontract. Sets the metrics toZERO_BD.
No Position for same Block Mint and burn
In certain scenarios, the position is minted and burnt within the same block. The contract call to NonfungiblePositionManager to retrieve position data reverts in such scenarios as the position no longer exists.
Entities
- Position - Read/Create Without Saving
ABI Dependencies:
- NonfungiblePositionManager.json
Dependencies:
Invoked at:
In addition to mainnet:
- initializes
position.collectedToken0andposition.collectedToken1values.
updateFeeVars()
Params:
- position (Position): The position for which the fee variables are set
- event (ethereum.Event): An event from the NFT Position Manager contract
- tokenId (BigInt): NFT Id for the staked position
ReturnType: Position
- Updates the fields
position.feeGrowthInside0LastX128andposition.feeGrowthInside1LastX128for the position represented bytokenIdby reading the value from theNonfungiblePositionManagertriggering theevent.
Entities
- Position - Update Fields Without Saving
ABI Dependencies:
- NonfungiblePositionManager.json
Invoked at:
savePositionSnapshot()
Params:
- position (Position): Position entity for which the current state is saved as a snapshot
- event (ethereum.Event): NonfungiblePositionManager Contract event after which the snapshot is being saved
ReturnType: void
- Saves the current values of a
Positionentity for future reference, including liquidity, tokens deposited and withdrawn, fee collected, feeGrowthInside.
Entities
- PositionSnapshot() - Create
Dependencies:
Invoked at:
handleIncreaseLiquidity()
Params:
- event (IncreaseLiquidity): Entity for a IncreaseLiquidity event emitted by NonfungiblePositionManager Contract
ReturnType: void
- Eth Mainnet
- Polygon
- Optimism
Ignored Blocks and Addresses
- Block 14317993 is ignored by the function.
- Pool address 0x8fe8d9bb8eeba3ed688069c3d6b556c9ca258248 (MULAN-USDT) is ignored by the function.
- Fetches the position entity using
getPosition(), passingevent.params.tokenIdandeventas parameters. - Updates fields
position.liquidity,position.depositedToken0andposition.depositedToken1. - Triggers
updateFeeVars()andsavePositionSnapshot()
Entities
Dependencies:
Invoked at:
handleDecreaseLiquidity()
Params:
- event (DecreaseLiquidity): Entity for a DecreaseLiquidity event emitted by NonfungiblePositionManager Contract
ReturnType: void
- Eth Mainnet
- Polygon
- Optimism
Ignored Blocks and Addresses
- Block 14317993 is ignored by the function.
- Pool address 0x8fe8d9bb8eeba3ed688069c3d6b556c9ca258248 (MULAN-USDT) is ignored by the function.
- Fetches the position entity using
getPosition(), passingevent.params.tokenIdandeventas parameters. - Updates fields
position.liquidity,position.withdrawnToken0andposition.withdrawnToken1. - Triggers
updateFeeVars()andsavePositionSnapshot()
Entities
Dependencies:
Invoked at:
handleCollect()
Params:
- event (Collect): Entity for a Collect event emitted by NonfungiblePositionManager Contract
ReturnType: void
Ignored Addresses
- Pool address 0x8fe8d9bb8eeba3ed688069c3d6b556c9ca258248 (MULAN-USDT) is ignored by the function.
- Eth Mainnet
- Polygon
- Optimism
- Fetches the position entity using
getPosition(), passingevent.params.tokenIdandeventas parameters. - Updates fields
position.collectedFeesToken0andposition.collectedFeesToken1by adding theevent.params.amount0after adjusting it withtoken.decimals. - Triggers
updateFeeVars()andsavePositionSnapshot()
Incorrect Collected Fees Token1 amount
event.params.amount0 (adjusted with token0.decimals) is added to both position.collectedFeesToken0 and position.collectedFeesToken1. This logic needs to be validated.
Entities
Dependencies:
Invoked at:
Differs from mainnet at the following areas:
- Updates fields
position.collectedToken0andposition.collectedToken1by adding theevent.params.amount0andevent.params.amount1after adjusting them withtoken.decimals. - Updates fields
position.collectedFeesToken0andposition.collectedFeesToken1by subtractingposition.withdrawnTokenfromposition.collectedToken. - Updates field
position.amountCollectedUSDby derivingamount0andamount1in their respective USD priced usingbundle.ethPriceUSDandtoken.derivedETHand adding to the existing value.
Additional Entities
- Bundle - Read
Differs from mainnet at the following areas:
- Returns without any changes if token0 or token1 entities are null.
- Updates fields
position.collectedToken0andposition.collectedToken1by adding theevent.params.amount0andevent.params.amount1after adjusting them withtoken.decimals. - Updates fields
position.collectedFeesToken0andposition.collectedFeesToken1by subtractingposition.withdrawnTokenfromposition.collectedToken.
Additional Entities Referenced
- Bundle - Read
handleTransfer()
Params:
- event (Transfer): Entity for a Transfer event emitted by NonfungiblePositionManager Contract
ReturnType: void
- Fetches the position entity using
getPosition(), passingevent.params.tokenIdandeventas parameters. - Sets
position.ownerwithevent.params.to. - Triggers
savePositionSnapshot().
Entities
- Position - Write