mirror of
https://github.com/Instadapp/dsa-resolvers-deprecated.git
synced 2024-07-29 22:38:16 +00:00
function names updates
This commit is contained in:
parent
1a04df42fd
commit
b54feece56
|
@ -3,7 +3,8 @@ pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
|
||||||
interface IERC20 {
|
interface IERC20 {
|
||||||
|
function balanceOf(address) external view returns (uint256);
|
||||||
|
function totalSupply() external view returns (uint256);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IGUniPool {
|
interface IGUniPool {
|
||||||
|
@ -17,35 +18,19 @@ interface IGUniPool {
|
||||||
|
|
||||||
function balanceOf(address account) external view returns (uint256);
|
function balanceOf(address account) external view returns (uint256);
|
||||||
|
|
||||||
// function mint(uint256 mintAmount, address receiver)
|
function getMintAmounts(uint256 amount0Max, uint256 amount1Max)
|
||||||
// external
|
external
|
||||||
// returns (
|
view
|
||||||
// uint256 amount0,
|
returns (
|
||||||
// uint256 amount1,
|
uint256 amount0,
|
||||||
// uint128 liquidityMinted
|
uint256 amount1,
|
||||||
// );
|
uint256 mintAmount
|
||||||
|
);
|
||||||
|
|
||||||
// function burn(uint256 burnAmount, address receiver)
|
function getPositionID() external view returns (bytes32 positionID);
|
||||||
// external
|
|
||||||
// returns (
|
|
||||||
// uint256 amount0,
|
|
||||||
// uint256 amount1,
|
|
||||||
// uint128 liquidityBurned
|
|
||||||
// );
|
|
||||||
|
|
||||||
// function getMintAmounts(uint256 amount0Max, uint256 amount1Max)
|
|
||||||
// external
|
|
||||||
// view
|
|
||||||
// returns (
|
|
||||||
// uint256 amount0,
|
|
||||||
// uint256 amount1,
|
|
||||||
// uint256 mintAmount
|
|
||||||
// );
|
|
||||||
|
|
||||||
// function getPositionID() external view returns (bytes32 positionID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IGUniRouter {
|
interface GUniResolver {
|
||||||
|
|
||||||
function getPoolUnderlyingBalances(IGUniPool pool)
|
function getPoolUnderlyingBalances(IGUniPool pool)
|
||||||
external
|
external
|
||||||
|
@ -54,10 +39,20 @@ interface IGUniRouter {
|
||||||
|
|
||||||
function getUnderlyingBalances(
|
function getUnderlyingBalances(
|
||||||
IGUniPool pool,
|
IGUniPool pool,
|
||||||
address account,
|
|
||||||
uint256 balance
|
uint256 balance
|
||||||
) external view returns (uint256 amount0, uint256 amount1);
|
) external view returns (uint256 amount0, uint256 amount1);
|
||||||
|
|
||||||
|
function getRebalanceParams(
|
||||||
|
IGUniPool pool,
|
||||||
|
uint256 amount0In,
|
||||||
|
uint256 amount1In,
|
||||||
|
uint16 slippageBPS
|
||||||
|
) external view returns (
|
||||||
|
bool zeroForOne,
|
||||||
|
uint256 swapAmount,
|
||||||
|
uint160 swapThreshold
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StakingRewardsInfo {
|
struct StakingRewardsInfo {
|
||||||
|
@ -108,7 +103,7 @@ contract DSMath {
|
||||||
contract Helpers is DSMath {
|
contract Helpers is DSMath {
|
||||||
|
|
||||||
StakingFactoryInterface public constant getStakingFactory = StakingFactoryInterface(0xf39eC5a471edF20Ecc7db1c2c34B4C73ab4B2C19);
|
StakingFactoryInterface public constant getStakingFactory = StakingFactoryInterface(0xf39eC5a471edF20Ecc7db1c2c34B4C73ab4B2C19);
|
||||||
IGUniRouter public constant gelatoRouter = IGUniRouter(0x8CA6fa325bc32f86a12cC4964Edf1f71655007A7);
|
GUniResolver public constant gelatoRouter = GUniResolver(address(0));
|
||||||
|
|
||||||
struct UserData {
|
struct UserData {
|
||||||
address pool; // address of pool contract
|
address pool; // address of pool contract
|
||||||
|
@ -150,11 +145,11 @@ contract Resolver is Helpers {
|
||||||
}
|
}
|
||||||
_data.poolBal = poolContract.balanceOf(user);
|
_data.poolBal = poolContract.balanceOf(user);
|
||||||
_data.totalBal = add(_data.stakedBal, _data.poolBal);
|
_data.totalBal = add(_data.stakedBal, _data.poolBal);
|
||||||
(_data.token0Bal, _data.token1Bal) = gelatoRouter.getUnderlyingBalances(poolContract, user, _data.totalBal);
|
(_data.token0Bal, _data.token1Bal) = gelatoRouter.getUnderlyingBalances(poolContract, _data.totalBal);
|
||||||
_data.poolTokenSupply = poolContract.balanceOf(user);
|
_data.poolTokenSupply = poolContract.balanceOf(user);
|
||||||
(_data.poolToken0Bal, _data.poolToken1Bal) = gelatoRouter.getPoolUnderlyingBalances(poolContract);
|
(_data.poolToken0Bal, _data.poolToken1Bal) = gelatoRouter.getPoolUnderlyingBalances(poolContract);
|
||||||
_data.poolTokenSupplyStaked = stakingContract.totalSupply();
|
_data.poolTokenSupplyStaked = stakingContract.totalSupply();
|
||||||
(_data.stakingToken0Bal, _data.stakingToken1Bal) = gelatoRouter.getUnderlyingBalances(poolContract, _data.staking, _data.poolTokenSupplyStaked);
|
(_data.stakingToken0Bal, _data.stakingToken1Bal) = gelatoRouter.getUnderlyingBalances(poolContract, _data.poolTokenSupplyStaked);
|
||||||
_data.rewardRate = stakingContract.rewardRate();
|
_data.rewardRate = stakingContract.rewardRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,4 +159,32 @@ contract Resolver is Helpers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @param slippage in 18 decimal where 100% = 1e18.
|
||||||
|
function getSwapAndDepositParams(
|
||||||
|
address pool,
|
||||||
|
uint amount0In,
|
||||||
|
uint amount1In,
|
||||||
|
uint slippage
|
||||||
|
) public view returns (
|
||||||
|
bool zeroForOne,
|
||||||
|
uint256 swapAmount,
|
||||||
|
uint160 swapThreshold
|
||||||
|
) {
|
||||||
|
uint slippageBPS = slippage / 1e16;
|
||||||
|
(zeroForOne, swapAmount, swapThreshold) = gelatoRouter.getRebalanceParams(IGUniPool(pool), amount0In, amount1In, uint16(slippageBPS));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param burnPercent in 18 decimal where 100% = 1e18.
|
||||||
|
* @param slippage in 18 decimal where 100% = 1e18.
|
||||||
|
*/
|
||||||
|
function getWithdrawParams(address user, address pool, uint burnPercent, uint slippage) public view returns (uint burnAmt, uint amount0, uint amount1, uint amount0Min, uint amount1Min) {
|
||||||
|
UserData memory _data = getSinglePosition(user, pool);
|
||||||
|
burnAmt = wmul(_data.totalBal, burnPercent);
|
||||||
|
amount0 = wmul(_data.token0Bal, burnPercent);
|
||||||
|
amount1 = wmul(_data.token1Bal, burnPercent);
|
||||||
|
amount0Min = wmul(amount0, sub(1e18, slippage));
|
||||||
|
amount1Min = wmul(amount1, sub(1e18, slippage));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user