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

bug in the CalcAmountOut function of curve's two pools #247

Open
mafangtao opened this issue Nov 29, 2023 · 1 comment
Open

bug in the CalcAmountOut function of curve's two pools #247

mafangtao opened this issue Nov 29, 2023 · 1 comment

Comments

@mafangtao
Copy link

There seems to be a bug in the CalcAmountOut function of curve's two pools. The calculation results are correct for some pools and wrong for others.

for example:

1-https://etherscan.io/tx/0x8d5ec325fb01a5fa9cf6c8795dbbfa0979e924eef04ba31810eab80ee16c2655#eventlog

The data on the chain is

sold_id:0
tokens_sold:
6521609294209082182
bought_id:1
tokens_bought:
1476425104436295904386
But the result of my calculation is
out.Fee : &{B 44901041 0}
out.SwapInfo :
out TokenAmountOut : 1476425104436295901193

2-https://etherscan.io/tx/0x6cc9b9e290cc78e0f7424935c071f11e001ca654ae21ac4702c79489d672f579

The data on the chain is:

sold_id:0
tokens_sold:
2000000000000000000
bought_id:1
tokens_bought:
179495139100822344170953

But the result of my calculation is
out.Fee : &{B 37401350 0}
out.SwapInfo :
out TokenAmountOut : 179495139100822346101543


There are other examples. Some addresses have factory contract type two-pool pools, and there are also non-factory contract type two-pool pools. They all have this problem. I carefully compared the vyper code on the chain, but still cannot find the problem.

@it4rb
Copy link
Member

it4rb commented Jan 4, 2024

@mafangtao : I cannot reproduce the issue with the latest state of above 2 pools, our simulation code yield the same results with forge/foundry (onchain simulation).

Is this still happen at your side? Next time it happen please capture the entity.Pool used for creating the simulator (something similar to this) and paste it here.

Thanks!

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

No branches or pull requests

2 participants