From a154c76398b6de24198e601462c98e7769650fba Mon Sep 17 00:00:00 2001 From: Samyak Jain <34437877+KaymasJain@users.noreply.github.com> Date: Sat, 12 Jun 2021 03:18:00 +0530 Subject: [PATCH] added token decimals & ticks --- .../protocols/mainnet/GelatoUniV3pool.sol | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/contracts/protocols/mainnet/GelatoUniV3pool.sol b/contracts/protocols/mainnet/GelatoUniV3pool.sol index f471959..1b97b48 100644 --- a/contracts/protocols/mainnet/GelatoUniV3pool.sol +++ b/contracts/protocols/mainnet/GelatoUniV3pool.sol @@ -5,6 +5,24 @@ pragma experimental ABIEncoderV2; interface IERC20 { function balanceOf(address) external view returns (uint256); function totalSupply() external view returns (uint256); + function decimals() external view returns (uint256); +} + +interface IUniswapV3Pool { + + function slot0() + external + view + returns ( + uint160 sqrtPriceX96, + int24 tick, + uint16 observationIndex, + uint16 observationCardinality, + uint16 observationCardinalityNext, + uint8 feeProtocol, + bool unlocked + ); + } interface IGUniPool { @@ -12,6 +30,8 @@ interface IGUniPool { function token1() external view returns (IERC20); + function pool() external view returns (IUniswapV3Pool); + function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); @@ -26,6 +46,12 @@ interface IGUniPool { ); function getPositionID() external view returns (bytes32 positionID); + + function lowerTick() external view returns (int24); + + function upperTick() external view returns (int24); + + } interface GUniResolver { @@ -121,6 +147,11 @@ contract Helpers is DSMath { uint stakedBal; // user's pool token bal in staking contract uint poolBal; // ideal pool token in user's DSA uint totalBal; // stakedBal + poolTknBal + uint token0Decimals; + uint token1Decimals; + int24 currentTick; + int24 lowerTick; + int24 upperTick; } } @@ -149,6 +180,14 @@ contract Resolver is Helpers { _data.poolTokenSupplyStaked = stakingContract.totalSupply(); (_data.stakingToken0Bal, _data.stakingToken1Bal) = gelatoRouter.getUnderlyingBalances(poolContract, _data.poolTokenSupplyStaked); _data.rewardRate = stakingContract.rewardRate(); + + _data.token0Decimals = poolContract.token0().decimals(); + _data.token1Decimals = poolContract.token1().decimals(); + + IUniswapV3Pool uniNft = poolContract.pool(); + (, _data.currentTick, , , , , ) = uniNft.slot0(); + _data.lowerTick = poolContract.lowerTick(); + _data.upperTick = poolContract.upperTick(); } function getPosition(address user, address[] memory pools) public view returns(UserData[] memory _data) { @@ -202,4 +241,4 @@ contract Resolver is Helpers { amount1Min = wmul(amount1, sub(1e18, slippage)); } -} +} \ No newline at end of file