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

feat: Set max n_coins on stable swap. added explanation of ann #181

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified precompile/binaries/stdlib/stableswap.mv
Binary file not shown.
7 changes: 5 additions & 2 deletions precompile/modules/initia_stdlib/sources/stableswap.move
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ module initia_std::stableswap {

const A_PRECISION: u256 = 100;

const MAX_N_COINS: u64 = 5;

struct ModuleStore has key {
pools: Table<address, bool>,
pool_count: u64
Expand All @@ -24,7 +26,8 @@ module initia_std::stableswap {
struct Pool has key {
/// Extend Reference
extend_ref: ExtendRef,
/// ANN
/// ANN, calculated as A * n ** n * A_PRECISION, where A is the amplification factor.
/// All `ann` values remain consistent with this formula.
ann: Ann,
/// swap fee
swap_fee_rate: BigDecimal,
Expand Down Expand Up @@ -562,7 +565,7 @@ module initia_std::stableswap {
ann: u64
): FungibleAsset acquires Pool, ModuleStore {
assert!(
vector::length(&coins) >= 2,
vector::length(&coins) >= 2 && vector::length(&coins) <= MAX_N_COINS,
error::invalid_argument(EN_COINS)
);
let (_, timestamp) = block::get_block_info();
Expand Down
Loading