Crate xyk

Source
Expand description

The constant product invariant calculator.

Structs§

SwapResult
Encodes all results of swapping from a source token to a destination token
TradingTokenResult
Encodes results of depositing both sides at once

Enums§

RoundDirection
The direction to round. Used for pool token to trading token conversions to avoid losing value on any deposit or withdrawal.

Constants§

MINIMUM_LIQUIDITY

Functions§

calculate_initial_swap_pool_amount
Initial amount of pool tokens for swap contract, calculated as the geometric mean of the two initial token liquidity amounts.
pool_tokens_to_trading_tokens
Get the amount of trading tokens for the given amount of pool tokens, provided the total trading tokens and supply of pool tokens.
swap
Constant product swap ensures x * y = constant