Skip to content
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

WIP CurveRecipe #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

WIP CurveRecipe #2

wants to merge 2 commits into from

Conversation

dantop114
Copy link

@dantop114 dantop114 commented Feb 22, 2021

Some considerations about this WIP:

  • _bake was written supposing that IPie.calcTokensForAmount() returns (_, uint256[] amounts) where amounts contains the amount of _inputToken to spend for each underlying asset
  • Does IPie.joinPool(uint256) receive the amount of _inputToken from which thepie is baked/minted?

Now some considerations about the implementation and possible edits:

  • Gas consumption will be huge on this (basically ICurveExchange.get_best_rate requires a lot of gas). We should think about exposing a pure function as: getBestPools(address _inputToken, address[] _outputTokens) that returns something like address[] pools, representing the best pools. This can be encoded (like in UniPieRecipe) and passed in the data field to bake.

@dantop114 dantop114 changed the title WIP CurveRecipe - Issue #1 WIP CurveRecipe Feb 22, 2021
@dantop114
Copy link
Author

dantop114 commented Feb 24, 2021

Last commit adds a script to estimate gas for get_best_rate function in Swap Curve contract in scripts/curveExchangeTest.ts.

Results from the script:

Curve Swap contract address: 0xD1602F68CC7C4c7B59D686243EA35a9C73B0c6a2
Gas estimation for get_best_rate: 1603971
Best pool is 0x06364f10B501e868329afBc005b3492902d6C763 receiving 99925715633714086595 DAI

So gas cost for get_best_rate should be 1603971. In CurveRecipe contract, this function is called n times (where n is the number of underlying tokens). Supposing a price of 100 gwei gas price: 1603971 * 100 gwei = 160397100 gwei = 0,1603971 ETH (just for a single call to get_best_rate)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant