We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
To replicate:
boa.env.fork("https://eth.llamarpc.com") pool = boa.load_partial('./contracts/CurveStableSwapNG.vy').at('0x383E6b4437b59fff47B619CBA855CA29342A8559') views = boa.load_partial('./contracts/CurveStableSwapNGViews.vy').at('0xe0B15824862f3222fdFeD99FeBD0f7e0EC26E1FA') coin_0 = boa.load_partial('./contracts/ERC20Mock.vy').at(pool.coins(0)) amounts = [500000000, 0] calculated_output = pool.calc_token_amount(amounts, True) with boa.env.prank('0x7E4B4DC22111B84594d9b7707A8DCFFd793D477A'), boa.env.anchor(): coin_0.approve(pool.address, 2**256-1) actual_output = pool.add_liquidity(amounts, 0)
calculated_output is 499505730367411984853 whereas actual_output is 499594877358336511794.
calculated_output
499505730367411984853
actual_output
499594877358336511794
The issue is caused by the calc_token_amount in the view contract:
for i in range(MAX_COINS): if i == N_COINS: break ideal_balance: uint256 = D1 * old_balances[i] / D0 difference: uint256 = 0 new_balance: uint256 = new_balances[i] if ideal_balance > new_balance: difference = ideal_balance - new_balance else: difference = new_balance - ideal_balance xs = old_balances[i] + new_balance _dynamic_fee_i = self._dynamic_fee(xs, ys, base_fee, fee_multiplier) new_balances[i] -= _dynamic_fee_i * difference / FEE_DENOMINATOR
which should be:
... xs = rates[i] * (old_balances[i] + new_balance) / PRECISION ...
To confirm this fix, please refer to the shared notebook here.
The text was updated successfully, but these errors were encountered:
AlbertoCentonze
Successfully merging a pull request may close this issue.
Description
To replicate:
calculated_output
is499505730367411984853
whereasactual_output
is499594877358336511794
.Fix
The issue is caused by the calc_token_amount in the view contract:
which should be:
To confirm this fix, please refer to the shared notebook here.
Task list
The text was updated successfully, but these errors were encountered: