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

chore: prevent creating stable pool when a=0 #921

Merged
merged 1 commit into from
Feb 9, 2023

Conversation

gregdhill
Copy link
Member

@gregdhill gregdhill commented Feb 9, 2023

Signed-off-by: Gregory Hill [email protected]

Errors occur here:

let denominator = ann
.checked_sub(a_precision)
.and_then(|n| n.checked_mul(d))
.and_then(|n| n.checked_div(a_precision))
.and_then(|n| {
n.checked_add(
U256::from(n_currencies)
.checked_add(U256::from(1u32))?
.checked_mul(d_p)?,
)
})?;
d = numerator.checked_div(denominator)?;

c = c
.checked_mul(d)?
.checked_mul(a_percision)?
.checked_div(ann.checked_mul(n_currencies)?)?;
let b = sum.checked_add(d.checked_mul(a_percision)?.checked_div(ann)?)?;

Same issue in Acala implementation: https://github.com/nutsfinance/stable-asset/blob/9a60645bc60e1c3452e8313de43179c4ba9b6e36/lib/stable-asset/src/lib.rs#L844

Related: https://github.com/saber-hq/stable-swap/blob/c621f5950e8071aaa595bc9ad674e970fccebdb2/stable-swap-math/src/curve.rs#L22

@gregdhill gregdhill merged commit ec01398 into interlay:master Feb 9, 2023
@gregdhill gregdhill deleted the chore/min-a branch February 9, 2023 14:45
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

Successfully merging this pull request may close these issues.

2 participants