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:

  1. Get current D
  2. Solve Eqn against y_i for D - _token_amount

Compute SwapResult after an exchange

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.