-
Notifications
You must be signed in to change notification settings - Fork 385
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
chore: make calc_withdraw_one_coin simulation consistent with _calc_withdraw_one_coin #86
base: master
Are you sure you want to change the base?
Conversation
0b06d9e
to
d64a10d
Compare
Ohh very nice |
Hmm...not sure what to do about these timeouts. @iamdefinitelyahuman @michwill any tips? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to merge! Anyone has any more comments?
Yeah, idk why timeouts |
Seems the new test in |
I will give that a try and report back. |
@@ -148,7 +148,7 @@ def remove_liquidity_imbalance(self, amounts): | |||
|
|||
def calc_withdraw_one_coin(self, token_amount, i): | |||
xp = self.xp() | |||
xp_reduced = xp | |||
xp_reduced = list(xp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you
@@ -166,6 +166,6 @@ def calc_withdraw_one_coin(self, token_amount, i): | |||
self.x = [x // (p // 10 ** 18) for x, p in zip(xp_reduced, self.p)] | |||
dy = xp_reduced[i] - self.y_D(i, D1) | |||
self.x = [x // (p // 10 ** 18) for x, p in zip(xp, self.p)] | |||
dy_0 = (xp[i] - new_y) | |||
dy_0 = xp[i] - new_y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you
curve_model = Curve(swap.A(), balances, n_coins, tokens=pool_token.totalSupply()) | ||
expected, _ = curve_model.calc_withdraw_one_coin(amount, idx) | ||
|
||
assert swap.swap.calc_withdraw_one_coin(amount, idx) == expected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you
curve_model = Curve(swap.A(), balances, n_coins, tokens=pool_token.totalSupply()) | ||
expected, _ = curve_model.calc_withdraw_one_coin(amount, idx) | ||
|
||
assert swap.calc_withdraw_one_coin(amount, idx) == expected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you
What I did
Change
calc_withdraw_one_coin
in simulation.py to represent the source of truth instead of approximation.How I did it
Made
calc_withdraw_one_coin
in simulation.py to exhibit the same behavior as_calc_withdraw_one_coin
How to verify it
Added test