fix small issues

This commit is contained in:
cryptoDev222 2021-08-09 09:58:28 -05:00
parent 08d24f1ef5
commit ab29b12a4e
2 changed files with 59 additions and 10 deletions

View File

@ -15,9 +15,9 @@ abstract contract Helpers is DSMath, Basic {
/**
* @dev uniswap v3 NFT Position Manager & Swap Router
*/
INonfungiblePositionManager nftManager =
INonfungiblePositionManager constant nftManager =
INonfungiblePositionManager(0xC36442b4a4522E871399CD717aBDD847Ab11FE88);
ISwapRouter swapRouter =
ISwapRouter constant swapRouter =
ISwapRouter(0xE592427A0AEce92De3Edee1F18E0157C05861564);
struct MintParams {
@ -88,7 +88,9 @@ abstract contract Helpers is DSMath, Basic {
function _addLiquidity(
uint256 _tokenId,
uint256 _amount0Desired,
uint256 _amount1Desired
uint256 _amount1Desired,
uint256 _amount0Min,
uint256 _amount1Min,
)
internal
returns (
@ -102,8 +104,8 @@ abstract contract Helpers is DSMath, Basic {
_tokenId,
_amount0Desired,
_amount1Desired,
0,
0,
_amount0Min,
_amount1Min,
block.timestamp
);
(liquidity, amount0, amount1) = nftManager.increaseLiquidity(params);
@ -114,14 +116,16 @@ abstract contract Helpers is DSMath, Basic {
*/
function _decreaseLiquidity(
uint256 _tokenId,
uint128 _liquidity
uint128 _liquidity,
uint256 _amount0Min,
uint256 _amount1Min,
) internal returns (uint256 amount0, uint256 amount1) {
INonfungiblePositionManager.DecreaseLiquidityParams
memory params = INonfungiblePositionManager.DecreaseLiquidityParams(
_tokenId,
_liquidity,
0,
0,
_amount0Min,
_amount0Min,
block.timestamp
);
(amount0, amount1) = nftManager.decreaseLiquidity(params);

View File

@ -45,6 +45,8 @@ abstract contract UniswapResolver is Helpers, Events {
* @param tokenId: NFT LP Token ID.
* @param amountA: tokenA amounts.
* @param amountB: tokenB amounts.
* @param amountAMin: Min amount of tokenA.
* @param amountBMin: Min amount of tokenB.
* @param getIds: IDs to retrieve token amounts
* @param setId: stores the amount of LP token
*/
@ -52,6 +54,8 @@ abstract contract UniswapResolver is Helpers, Events {
uint256 tokenId,
uint256 amountA,
uint256 amountB,
uint256 amountAMin,
uint256 amountBMin,
uint256[] calldata getIds,
uint256 setId
)
@ -65,7 +69,9 @@ abstract contract UniswapResolver is Helpers, Events {
(uint256 _liquidity, uint256 _amtA, uint256 _amtB) = _addLiquidity(
tokenId,
amtA,
amtB
amtB,
amountAMin,
amountBMin
);
setUint(setId, _liquidity);
@ -77,12 +83,16 @@ abstract contract UniswapResolver is Helpers, Events {
* @dev Decrease Liquidity
* @param tokenId: NFT LP Token ID.
* @param liquidity: LP Token amount.
* @param amountAMin: Min amount of tokenA.
* @param amountBMin: Min amount of tokenB.
* @param getId: ID to retrieve LP token amounts
* @param setIds: stores the amount of output tokens
*/
function decreateLiquidity(
uint256 tokenId,
uint128 liquidity,
uint256 amountAMin,
uint256 amountBMin,
uint256 getId,
uint256[] calldata setIds
)
@ -94,7 +104,9 @@ abstract contract UniswapResolver is Helpers, Events {
(uint256 _amtA, uint256 _amtB) = _decreaseLiquidity(
tokenId,
_liquidity
_liquidity,
amountAMin,
amountBMin
);
setUint(setIds[0], _amtA);
@ -138,6 +150,39 @@ abstract contract UniswapResolver is Helpers, Events {
_eventName = "swap(address,address,uint256,uint256)";
_eventParam = abi.encode(tokenIn, tokenOut, _amountIn, amountOut);
}
/**
* @dev Collect function
* @param tokenId: NFT LP Token ID.
* @param amount0Max: Max amount of token0.
* @param amount1Max: Max amount of token1.
* @param getIds: IDs to retrieve amounts
* @param setIds: stores the amount of output tokens
*/
function collect(
uint256 tokenId,
uint128 amount0Max,
uint128 amount1Max,
uint256[] calldata getIds,
uint256[] calldata setIds
)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
uint128 _amount0Max = getUint(getIds[0], amount0Max);
uint128 _amount1Max = getUint(getIds[1], amount1Max);
(uint256 amount0, uint256 amount1) = _collect(
tokenId,
_amount0Max,
_amount1Max
);
setUint(setIds[0], amount0);
setUint(setIds[1], amount1);
_eventName = "collect(uint256,uint256,uint256)";
_eventParam = abi.encode(tokenId, amount0, amount1);
}
}
contract ConnectV2UniswapV3 is UniswapResolver {