Skip to content

Instantly share code, notes, and snippets.

@sanandnarayan
Created June 15, 2023 05:57
Show Gist options
  • Save sanandnarayan/7bc43beb5857d9fb63214a8337574dfc to your computer and use it in GitHub Desktop.
Save sanandnarayan/7bc43beb5857d9fb63214a8337574dfc to your computer and use it in GitHub Desktop.
IPositionsHelper
// SPDX-License-Identifier: UNLICENSED
pragma solidity <=0.8.20;
import "v3-periphery/interfaces/INonfungiblePositionManager.sol";
// https://github.com/Uniswap/v3-periphery/blob/0.8/contracts/interfaces/INonfungiblePositionManager.sol
interface IPositionsHelper {
struct Position {
uint96 nonce;
address operator;
address token0;
address token1;
uint24 fee;
int24 tickLower;
int24 tickUpper;
uint128 liquidity;
uint256 feeGrowthInside0LastX128;
uint256 feeGrowthInside1LastX128;
uint128 tokensOwed0;
uint128 tokensOwed1;
}
function getTokenAmounts(address positionManager, uint256 lpTokenID)
external
returns (Position memory);
}
contract PositionsHelper is IPositionsHelper {
function getTokenAmounts(address positionManager, uint256 lpTokenID)
external
returns (Position memory position)
{
{
(,, position.token0, position.token1,,,,,,,,) =
INonfungiblePositionManager(positionManager).positions(lpTokenID);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment