Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR was originally targeting the SetV2 repo. Discussion can be found here: SetProtocol#259
TODO: Upgrade to Solidity 0.8
TODO: Replace any Set Protocol deployed addresses with their Index Protocol equivalent.
Text from original PR by DeePhil:
There are a few things to consider about the CurveAmmAdapter.
All curve pools have 2 ~ 4 component coins.
CVXETH - 0x3A283D9c08E8b55966afb64C515f5143cf907611 (two tokens - WETH/CVX)
TRICRYPTO - 0xc4AD29ba4B3c580e6D59105FFf484999997675Ff (three tokens - USDT/WBTC/WETH)
There is no generalized query function to get component coin count of the pool.
To support different number of component coins, the CurveAmmAdapter will accept coinCount in constructor.
Each curve pool has token contract (which has IERC20 standard interface) and minter contract (which has addLiquidity / removeLiquidity functionality).
Example curve pool with different token/minter contract address
CVXETH token contract - 0x3A283D9c08E8b55966afb64C515f5143cf907611
CVXETH minter contract - 0xb576491f1e6e5e62f1d8f26062ee822b40b0e0d4
Example curve pool with same token/minter contract address
MIM token contract - 0x5a6A4D54456819380173272A5E8E9B9904BdF41B
MIM minter contract - 0x5a6A4D54456819380173272A5E8E9B9904BdF41B
Since some has the same token/minter contract and some has different token/minter contract, the CurveAmmAdapter will accept poolToken and poolMinter contract addresses in constructor.
The curve pools support removeLiquidityOneCoin functionality, but some pools use int128 for the coin index, some pools use uint256 for the coin index.
MIM token contract - 0x5a6A4D54456819380173272A5E8E9B9904BdF41B (use int128 for the coin index)
TRICRYPTO - 0xc4AD29ba4B3c580e6D59105FFf484999997675Ff (use uint256 for the coin index)
To solve this problem, the CurveAmmAdapter will accept a flag that tells if the pool uses int128 or uint256 for coin index.
The curve pools has addLiquidity and removeLiquidity functionality but it doesn't accept any recipient address. So we can't specify setToken address in the calldata.
This is fixed by introducing addLiquidity, removeLiquidity and removeLiquidityOneCoin wrapper functions in CurveAmmAdapter contract.
E.g. addLiquidity wrapper function will accept the recipient address. It will get component tokens from msg.sender, add liquidity & mint pool tokens, transfer pool tokens back to recipient address.