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

exchange gives incorrect result #220

Closed
chanhosuh opened this issue Sep 5, 2023 · 2 comments · Fixed by #239
Closed

exchange gives incorrect result #220

chanhosuh opened this issue Sep 5, 2023 · 2 comments · Fixed by #239
Assignees
Labels
bug Something isn't working
Milestone

Comments

@chanhosuh
Copy link
Member

Version Information

  • Output of python -m curvesim --version (curvesim and python versions, OS type)
$ python -m curvesim --version
curvesim 0.5.0.b1, CPython 3.10.0 on Darwin

What's your issue about?

>> import curvesim
>> pool = curvesim.pool.get("0x5426178799ee0a0181a89b4f57efddfab49941ec", env='staging')
>> pool.exchange(1, 0, 10**18)
(199111088072776543986652, 598819974073168473476)

this is the TricryptoINV pool, which holds USDC, ETH, INV (~$200k each), so 1 ETH will give you almost all the USDC in the pool

How can it be fixed?

No idea. Needs further investigation.

@chanhosuh chanhosuh added the bug Something isn't working label Sep 5, 2023
@chanhosuh
Copy link
Member Author

Seems like the D in the pool snapshot is wrong (roughly 1/3rd the actual value). However, the "snapshot" isn't actually pulling the value of D from the subgraph but computing it itself (using stableswap logic). We should remove computational logic from the snapshot flow entirely to avoid these issues.

@chanhosuh
Copy link
Member Author

After some discussion, seems like the reason we have the D computation as part of the snapshot is for creating balanced pools for sims. We can just do that explicitly in the get_sim_pool factory function. The snapshot itself should not have heavy computational logic in it. This is best left to the pool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant