SetProtocol / set-protocol-v2

Set Protocol V2
119 stars 94 forks source link

Support Curve stableswap pools #253

Closed FlattestWhite closed 2 years ago

FlattestWhite commented 2 years ago

Code Review Processes

Curve pools can have 2, 3 or even 4 coins in a pool. However, from an exchange perspective, we'd only ever be swapping two coins at one time. Furthermore, most coins in all pools are ERC20 tokens. Hence the eth/steth pool needed some extra logic around wrapping and unwrapping for eth/weth. The approach taken with this adapter is to assume we're only going to be trading ERC20 tokens.

It assumes both tokens that are being traded are ERC20 tokens and it requires the index on of the coin on the curve pool to be passed in at construction. The rest is just a simple encoding of the exchange function.

Newer curve pools also have an exchange function that can take a destination address as the last argument. This means we can save an extra contract call. However, most existing curve pools don't support that new exchange method. Hence, I've decided to use the older more widesperad "exchange" method, but it requires doing an extra transfer of tokens back to the user.

New Feature Review

Before submitting a pull request for new review, make sure the following is done:

README Checks

Code Checks

Broader Considerations

FlattestWhite commented 2 years ago

Added forked integration tests - and fixed up the assertions so they're passing. Also added comments to explain why the assertions are the way they are.

FlattestWhite commented 2 years ago

LGTM! Thanks for the additional tests and the clarifying comments - very helpful.

Thanks - will your team merge and write the deploy script? Or will you need me to do so?

cgewecke commented 2 years ago

@FlattestWhite Just merged - we will deploy the adapter. I've asked some questions about how to parameterize the deployment in a slack channel Set shares with IC which Ed added you to yesterday.

Will continue discussion there :)

cgewecke commented 2 years ago

:tada: This PR is included in version 0.10.3-hhat.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: