mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
fix small issues
This commit is contained in:
parent
3fb91b6136
commit
944b3fb130
|
@ -40,34 +40,6 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
minAmt = convert18ToDec(token.decimals(), minAmt);
|
minAmt = convert18ToDec(token.decimals(), minAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortTokens(
|
|
||||||
address tokenA,
|
|
||||||
address tokenB,
|
|
||||||
uint256 amtA,
|
|
||||||
uint256 amtB
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (
|
|
||||||
TokenInterface token0,
|
|
||||||
TokenInterface token1,
|
|
||||||
uint256 amt0,
|
|
||||||
uint256 amt1
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (tokenA > tokenB) {
|
|
||||||
token1 = TokenInterface(tokenA);
|
|
||||||
token0 = TokenInterface(tokenB);
|
|
||||||
amt1 = amtA;
|
|
||||||
amt0 = amtB;
|
|
||||||
} else {
|
|
||||||
token0 = TokenInterface(tokenA);
|
|
||||||
token1 = TokenInterface(tokenB);
|
|
||||||
amt0 = amtA;
|
|
||||||
amt1 = amtB;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Mint function which interact with Uniswap v3
|
* @dev Mint function which interact with Uniswap v3
|
||||||
*/
|
*/
|
||||||
|
@ -88,17 +60,10 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
uint256 _amount0 = params.amtA == uint256(-1)
|
uint256 _amount0 = params.amtA == uint256(-1)
|
||||||
? getTokenBal(TokenInterface(params.tokenA))
|
? getTokenBal(TokenInterface(params.tokenA))
|
||||||
: params.amtA;
|
: params.amtA;
|
||||||
uint256 _amount1 = params.amtA == uint256(-1)
|
uint256 _amount1 = params.amtB == uint256(-1)
|
||||||
? getTokenBal(TokenInterface(params.tokenA))
|
? getTokenBal(TokenInterface(params.tokenB))
|
||||||
: params.amtB;
|
: params.amtB;
|
||||||
|
|
||||||
(_token0, _token1, _amount0, _amount1) = sortTokens(
|
|
||||||
params.tokenA,
|
|
||||||
params.tokenB,
|
|
||||||
_amount0,
|
|
||||||
_amount1
|
|
||||||
);
|
|
||||||
|
|
||||||
uint256 isEth = address(_token0) == wethAddr ? 0 : 2;
|
uint256 isEth = address(_token0) == wethAddr ? 0 : 2;
|
||||||
isEth = address(_token1) == wethAddr ? 1 : 2;
|
isEth = address(_token1) == wethAddr ? 1 : 2;
|
||||||
convertEthToWeth(isEth == 0, _token0, _amount0);
|
convertEthToWeth(isEth == 0, _token0, _amount0);
|
||||||
|
@ -138,7 +103,7 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
(, , address token0, address token1, , , , , , , , ) = nftManager
|
(, , address token0, address token1, , , , , , , , ) = nftManager
|
||||||
.positions(_tokenId);
|
.positions(_tokenId);
|
||||||
uint256 isEth = token0 == wethAddr ? 0 : 2;
|
uint256 isEth = token0 == wethAddr ? 0 : 2;
|
||||||
isEth = token0 == wethAddr ? 1 : 2;
|
isEth = token1 == wethAddr ? 1 : 2;
|
||||||
convertEthToWeth(isEth == 0, TokenInterface(token0), _amount0);
|
convertEthToWeth(isEth == 0, TokenInterface(token0), _amount0);
|
||||||
convertEthToWeth(isEth == 1, TokenInterface(token1), _amount1);
|
convertEthToWeth(isEth == 1, TokenInterface(token1), _amount1);
|
||||||
approve(TokenInterface(token0), address(nftManager), _amount0);
|
approve(TokenInterface(token0), address(nftManager), _amount0);
|
||||||
|
@ -200,15 +165,15 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
*/
|
*/
|
||||||
function _collect(
|
function _collect(
|
||||||
uint256 _tokenId,
|
uint256 _tokenId,
|
||||||
uint128 _amount0Max,
|
uint256 _amount0Max,
|
||||||
uint128 _amount1Max
|
uint256 _amount1Max
|
||||||
) internal returns (uint256 amount0, uint256 amount1) {
|
) internal returns (uint256 amount0, uint256 amount1) {
|
||||||
INonfungiblePositionManager.CollectParams
|
INonfungiblePositionManager.CollectParams
|
||||||
memory params = INonfungiblePositionManager.CollectParams(
|
memory params = INonfungiblePositionManager.CollectParams(
|
||||||
_tokenId,
|
_tokenId,
|
||||||
address(this),
|
address(this),
|
||||||
_amount0Max,
|
uint128(_amount0Max),
|
||||||
_amount1Max
|
uint128(_amount1Max)
|
||||||
);
|
);
|
||||||
(amount0, amount1) = nftManager.collect(params);
|
(amount0, amount1) = nftManager.collect(params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ abstract contract UniswapResolver is Helpers, Events {
|
||||||
* @param getId: ID to retrieve LP token amounts
|
* @param getId: ID to retrieve LP token amounts
|
||||||
* @param setIds: stores the amount of output tokens
|
* @param setIds: stores the amount of output tokens
|
||||||
*/
|
*/
|
||||||
function decreateLiquidity(
|
function decreaseLiquidity(
|
||||||
uint256 tokenId,
|
uint256 tokenId,
|
||||||
uint128 liquidity,
|
uint128 liquidity,
|
||||||
uint256 amountAMin,
|
uint256 amountAMin,
|
||||||
|
@ -199,5 +199,5 @@ abstract contract UniswapResolver is Helpers, Events {
|
||||||
}
|
}
|
||||||
|
|
||||||
contract ConnectV2UniswapV3 is UniswapResolver {
|
contract ConnectV2UniswapV3 is UniswapResolver {
|
||||||
string public constant name = "UniswapV3-v1.1";
|
string public constant name = "UniswapV3-v1";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user