Struct stable_swap::curve::StableSwap [−][src]
pub struct StableSwap { /* fields omitted */ }
Expand description
The StableSwap invariant calculator.
Implementations
New StableSwap calculator
Compute the amplification coefficient (A)
Compute stable swap invariant (D) Equation: A * sum(x_i) * nn + D = A * D * nn + D**(n+1) / (n**n * prod(x_i))
Compute the amount of pool tokens to mint after a deposit
Compute swap amount y
in proportion to x
Solve for y:
y2 + y * (sum’ - (A*nn - 1) * D / (A * nn)) = D ** (n + 1) / (n ** (2 * n) * prod’ * A)
y2 + b*y = c
Compute swap amount y
in proportion to x
Calculate withdrawal amount when withdrawing only one type of token Calculation:
- Get current D
- Solve Eqn against y_i for D - _token_amount