-
Notifications
You must be signed in to change notification settings - Fork 55
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] Stable swap implementation #48
base: main
Are you sure you want to change the base?
Conversation
d_prod: U256, | ||
sum_x: Balance, | ||
) -> Option<U256> { | ||
let ann = amp_factor.checked_mul(N_COINS.into())?; |
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.
I guess ann should be amp_factor * N ** N
, but here is amp_factor * N
.checked_div(x.checked_mul(N_COINS.into())?.into())?; | ||
c = c | ||
.checked_mul(d)? | ||
.checked_div(ann.checked_mul(N_COINS.into())?.into())?; |
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.
the code logic shows n ** (2+n)
but comment suggests n ** (2n)
for (idx, min_amount) in min_amounts.iter().enumerate() { | ||
if *min_amount != 0 { | ||
let (amount_out, fee) = invariant | ||
.compute_withdraw_one( |
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.
It seems compute_withdraw_one
has figured out the outcome for remove shares
with one type of token. When user want withdraw both tokens, each output token balance represent the shares, so cause an insistency with share reduced and tokens balances withdrawed.
When LP deposit and/or withdraw liquidity in a not perfect ratio, a fee will be charged. So, Why not we just suggest them to deposit and withdraw with perfect ratio to avoid fees? Is there any requirements that leads to support the unbalanced deposit/withdraw actions especially withdraw with one type of token? |
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.
Besides comments, I made some changes in my folk repo and initate a PR to this repo, please check it.
Adding a new type of pool for stable swap between two tokens that have equally priced.