-
Notifications
You must be signed in to change notification settings - Fork 103
Curve amm adapter #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Curve amm adapter #155
Conversation
for (uint256 i = 0; i < 2; i++) { | ||
if (underlying[i] == _token) return i; | ||
} | ||
revert("token not in pool"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think we have coverage on this revert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though this revert may not be necessary because of _isValidPool
we know that the passed components exist in that Meta Pool otherwise Line 160 would resolve false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, i deleted the revert
@@ -0,0 +1,9 @@ | |||
## Curve FactoryMetapool Amm Adapter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great context, lets put it in the javadocs in the adapter contract and remove this markdown file. We like to keep all the context in the contract itself.
import { IMetaPoolZap } from "../../../interfaces/external/IMetaPoolZap.sol"; | ||
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
||
contract CurveFactoryMetapoolAmmAdapter is IAmmAdapter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can add some of the javadocs and section headers you see here for consistency.
override | ||
returns (address, uint256, bytes memory) | ||
{ | ||
require(_isValidPool(_pool, _components), "invalid pool"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need this because this check comes standard on the AmmModule
, see here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, deleted it
override | ||
returns (address, uint256, bytes memory) | ||
{ | ||
require(_isValidPool(_pool, _components), "invalid pool"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above, this check is duplicated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, deleted it
address[2] memory expectedTokens = metapoolFactory.get_coins(_pool); | ||
|
||
for (uint256 i = 0; i < _components.length; i++) { | ||
if ((_components[i] == expectedTokens[0] || _components[i] == expectedTokens[1]) == false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can rewrite this as !(_components[i] == expectedTokens[0] || _components[i] == expectedTokens[1]) == false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Brian means:
!(_components[i] == expectedTokens[0] || _components[i] == expectedTokens[1])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure do
address[2] memory expectedTokens = metapoolFactory.get_coins(_pool); | ||
|
||
for (uint256 i = 0; i < _components.length; i++) { | ||
if ((_components[i] == expectedTokens[0] || _components[i] == expectedTokens[1]) == false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to check that there are no duplicates in the _components
array, right now this would pass if there was a duplicate that was one of the tokens in the AMM.
But since the AmmModule
is not yet deployed I say we make that check in the AmmModule
itself because I can't think of a scenario where an AMM would have "duplicate" components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would add that check here using AddressArrayUtils.hasDuplicate
which can be found in contracts/lib
using SafeCast for int256; | ||
|
||
IMetapoolFactory public metapoolFactory; | ||
address public constant THREE_CRV = address(0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would avoid hardcoding this.You can instead pass it to the constructor. This means it will work with other metapools by just doing a new deployment (such as the btc one).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be deleted actually because it's not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah its not in use anymore
address[2] memory expectedTokens = metapoolFactory.get_coins(_pool); | ||
|
||
for (uint256 i = 0; i < _components.length; i++) { | ||
if ((_components[i] == expectedTokens[0] || _components[i] == expectedTokens[1]) == false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Brian means:
!(_components[i] == expectedTokens[0] || _components[i] == expectedTokens[1])
IMetapoolFactory public metapoolFactory; | ||
address public constant THREE_CRV = address(0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490); | ||
|
||
string public constant ADD_LIQUIDITY = "add_liquidity(uint256[2],uint256,address)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to use the ITriPoolZap functions rather than the IMetaPoolZap ones. This function requires depositing a combination of the 3Pool token and the extra token. The ITriPoolZap interface lets you deposit any of the 3Pool's pools' underlying tokens and the extra token. Makes it a lot more usable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ncitron it turns out that this interface & adapter is specifically for the factory metapool and not the legacy metapools. Do you know if the TriPoolZap supports the factory metapools? we had issues with the TriPoolZap reverting without any reason string response, so we ended up switching focus to the factory metapool with the intention to revisit the Zap and legacy metapool implementation afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe they do. I had checked that it works on a whole list of pools. I think one of the gotchas on some of the different pools though is that the LP token address is different than the pool address though. I believe there is a contract for converting from LP token address to pool address and vice versa somewhere in the docs. I had previously confirmed that the zap contract works with the LUSD, alUSD, and USDN pools though (and IIRC alUSD is one of the legacy ones)
Closed in favor of #253 |
Code Review Processes
New Feature Review
Before submitting a pull request for new review, make sure the following is done:
README Checks
Code Checks
Broader Considerations