mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
fix mint function
This commit is contained in:
parent
ab29b12a4e
commit
1ae2a5c9e5
|
@ -21,13 +21,24 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
ISwapRouter(0xE592427A0AEce92De3Edee1F18E0157C05861564);
|
ISwapRouter(0xE592427A0AEce92De3Edee1F18E0157C05861564);
|
||||||
|
|
||||||
struct MintParams {
|
struct MintParams {
|
||||||
address tokenA;
|
address token0;
|
||||||
address tokenB;
|
address token1;
|
||||||
uint24 fee;
|
uint24 fee;
|
||||||
int24 tickLower;
|
int24 tickLower;
|
||||||
int24 tickUpper;
|
int24 tickUpper;
|
||||||
uint256 amtA;
|
uint256 amt1;
|
||||||
uint256 unitAmt;
|
uint256 unitAmt;
|
||||||
|
uint slippage;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMinAmount(
|
||||||
|
TokenInterface token,
|
||||||
|
uint amt,
|
||||||
|
uint slippage
|
||||||
|
) internal view returns(uint minAmt) {
|
||||||
|
uint _amt18 = convertTo18(token.decimals(), amt);
|
||||||
|
minAmt = wmul(_amt18, sub(WAD, slippage));
|
||||||
|
minAmt = convert18ToDec(token.decimals(), minAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,29 +53,25 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
uint256 amount1
|
uint256 amount1
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
(TokenInterface _tokenA, TokenInterface _tokenB) = changeEthAddress(
|
(TokenInterface _token0, TokenInterface _token1) = changeEthAddress(
|
||||||
params.tokenA,
|
params.token0,
|
||||||
params.tokenB
|
params.token1
|
||||||
);
|
);
|
||||||
|
|
||||||
uint256 _amount0 = params.amtA == uint256(-1)
|
uint256 _amount1 = params.amt1 == uint256(-1)
|
||||||
? getTokenBal(TokenInterface(params.tokenA))
|
? getTokenBal(TokenInterface(params.token1))
|
||||||
: params.amtA;
|
: params.amt1;
|
||||||
uint256 _amount1 = convert18ToDec(
|
uint256 _amount0 = convert18ToDec(
|
||||||
_tokenB.decimals(),
|
_token1.decimals(),
|
||||||
wmul(params.unitAmt, convertTo18(_tokenA.decimals(), _amount0))
|
wmul(params.unitAmt, convertTo18(_token1.decimals(), _amount1))
|
||||||
);
|
);
|
||||||
|
|
||||||
TransferHelper.safeApprove(
|
_token0.approve(address(nftManager), _amount0);
|
||||||
params.tokenA,
|
_token1.approve(address(nftManager), _amount1);
|
||||||
address(nftManager),
|
|
||||||
_amount0
|
uint _minAmt0 = getMinAmount(_token0, _amount0, params.slippage);
|
||||||
);
|
uint _minAmt1 = getMinAmount(_token1, _amount1, params.slippage);
|
||||||
TransferHelper.safeApprove(
|
|
||||||
params.tokenB,
|
|
||||||
address(nftManager),
|
|
||||||
_amount1
|
|
||||||
);
|
|
||||||
INonfungiblePositionManager.MintParams
|
INonfungiblePositionManager.MintParams
|
||||||
memory params = INonfungiblePositionManager.MintParams(
|
memory params = INonfungiblePositionManager.MintParams(
|
||||||
params.tokenA,
|
params.tokenA,
|
||||||
|
@ -74,8 +81,8 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
params.tickUpper,
|
params.tickUpper,
|
||||||
_amount0,
|
_amount0,
|
||||||
_amount1,
|
_amount1,
|
||||||
0,
|
_minAmt0,
|
||||||
0,
|
_minAmt1,
|
||||||
address(this),
|
address(this),
|
||||||
block.timestamp
|
block.timestamp
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user