-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: uniswapV3LiquidityPosition (#717)
* feat: add UniswapV3LiquidityPosition lib, parser, and helper contracts * chore: add uniswap peripheral contracts and openzeppelin solc 7 npm dependencies * refactor: copy necessary interfaces for use in this external position only, due to solc 7 * chore: add deployment scripts * chore: add helper utils * test: add test suite * chore: update codegen to handle contract namespace clashes Co-authored-by: Sean Casey <[email protected]>
- Loading branch information
1 parent
016e3ad
commit 702818b
Showing
30 changed files
with
2,392 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...persistent/external-positions/uniswap-v3-liquidity/UniswapV3LiquidityPositionLibBase1.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
/* | ||
This file is part of the Enzyme Protocol. | ||
(c) Enzyme Council <[email protected]> | ||
For the full license information, please view the LICENSE | ||
file that was distributed with this source code. | ||
*/ | ||
|
||
pragma solidity 0.7.6; | ||
|
||
/// @title UniswapV3LiquidityPositionLibBase1 Contract | ||
/// @author Enzyme Council <[email protected]> | ||
/// @notice A persistent contract containing all required storage variables and | ||
/// required functions for a UniswapV3LiquidityPositionLib implementation | ||
/// @dev DO NOT EDIT CONTRACT. If new events or storage are necessary, they should be added to | ||
/// a numbered UniswapV3LiquidityPositionLibBaseXXX that inherits the previous base. | ||
/// e.g., `UniswapV3LiquidityPositionLibBase2 is UniswapV3LiquidityPositionLibBase1` | ||
abstract contract UniswapV3LiquidityPositionLibBase1 { | ||
event Initialized(address token0, address token1); | ||
|
||
event NFTPositionAdded(uint256 indexed tokenId); | ||
|
||
event NFTPositionRemoved(uint256 indexed tokenId); | ||
|
||
uint256[] internal nftIds; | ||
// token0 and token1 are assigned deterministically by sort order, | ||
// so will be the same for all fees | ||
address internal token0; | ||
address internal token1; | ||
} |
93 changes: 93 additions & 0 deletions
93
...manager/external-positions/uniswap-v3-liquidity/UniswapV3LiquidityPositionDataDecoder.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
/* | ||
This file is part of the Enzyme Protocol. | ||
(c) Enzyme Council <[email protected]> | ||
For the full license information, please view the LICENSE | ||
file that was distributed with this source code. | ||
*/ | ||
|
||
pragma solidity 0.7.6; | ||
|
||
/// @title UniswapV3LiquidityPositionDataDecoder Contract | ||
/// @author Enzyme Council <[email protected]> | ||
/// @notice Abstract contract containing data decodings for UniswapV3LiquidityPosition payloads | ||
abstract contract UniswapV3LiquidityPositionDataDecoder { | ||
/// @dev Helper to decode args used during the AddLiquidity action | ||
function __decodeAddLiquidityActionArgs(bytes memory _actionArgs) | ||
internal | ||
pure | ||
returns ( | ||
uint256 nftId_, | ||
uint256 amount0Desired_, | ||
uint256 amount1Desired_, | ||
uint256 amount0Min_, | ||
uint256 amount1Min_ | ||
) | ||
{ | ||
return abi.decode(_actionArgs, (uint256, uint256, uint256, uint256, uint256)); | ||
} | ||
|
||
/// @dev Helper to decode args used during the Collect action | ||
function __decodeCollectActionArgs(bytes memory _actionArgs) | ||
internal | ||
pure | ||
returns (uint256 nftId_) | ||
{ | ||
return abi.decode(_actionArgs, (uint256)); | ||
} | ||
|
||
/// @dev Helper to decode args used during init() | ||
function __decodeInitArgs(bytes memory _initArgs) | ||
internal | ||
pure | ||
returns (address token0_, address token1_) | ||
{ | ||
return abi.decode(_initArgs, (address, address)); | ||
} | ||
|
||
/// @dev Helper to decode args used during the Mint action | ||
function __decodeMintActionArgs(bytes memory _actionArgs) | ||
internal | ||
pure | ||
returns ( | ||
uint24 fee_, | ||
int24 tickLower_, | ||
int24 tickUpper_, | ||
uint256 amount0Desired_, | ||
uint256 amount1Desired_, | ||
uint256 amount0Min_, | ||
uint256 amount1Min_ | ||
) | ||
{ | ||
return abi.decode(_actionArgs, (uint24, int24, int24, uint256, uint256, uint256, uint256)); | ||
} | ||
|
||
/// @dev Helper to decode args used during the Purge action | ||
function __decodePurgeActionArgs(bytes memory _actionArgs) | ||
internal | ||
pure | ||
returns ( | ||
uint256 nftId_, | ||
uint128 liquidity_, | ||
uint256 amount0Min_, | ||
uint256 amount1Min_ | ||
) | ||
{ | ||
return abi.decode(_actionArgs, (uint256, uint128, uint256, uint256)); | ||
} | ||
|
||
/// @dev Helper to decode args used during the RemoveLiquidity action | ||
function __decodeRemoveLiquidityActionArgs(bytes memory _actionArgs) | ||
internal | ||
pure | ||
returns ( | ||
uint256 nftId_, | ||
uint128 liquidity_, | ||
uint256 amount0Min_, | ||
uint256 amount1Min_ | ||
) | ||
{ | ||
return abi.decode(_actionArgs, (uint256, uint128, uint256, uint256)); | ||
} | ||
} |
Oops, something went wrong.