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()