diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fd868b..87cf597 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,13 +21,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Breaking Changes -## zap [0.2.1] [PR #15](https://github.com/MeteoraAg/zap-program/pull/41) +## zap [0.2.1] [PR #41](https://github.com/MeteoraAg/zap-program/pull/41) + +### Added + +- Added dammv1 swap as a zap out option ### Fixed -- Fix zap in damm-v2 with new base fee mode +- Fix zap in damm-v2 with new base fee mode ## zap [0.2.0] [PR #15](https://github.com/MeteoraAg/zap-program/pull/15) ### Added + New endpoints `initialize_ledger_account`, `close_ledger_account`, `set_ledger_balance`, `update_ledger_balance_after_swap`, `zap_in_damm_v2`, `zap_in_dlmm_for_initialized_position` and `zap_in_dlmm_for_uninitialized_position` that allow user to zap in damm v2 and dlmm easily. Refer `ZAPIN.md` for zap_in examples diff --git a/Cargo.lock b/Cargo.lock index ebe94d9..64060f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3550,7 +3550,7 @@ dependencies = [ [[package]] name = "zap" -version = "0.2.0" +version = "0.2.1" dependencies = [ "anchor-lang", "anchor-spl", diff --git a/idls/damm_v1.json b/idls/damm_v1.json new file mode 100644 index 0000000..75266e6 --- /dev/null +++ b/idls/damm_v1.json @@ -0,0 +1,4807 @@ +{ + "address": "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB", + "metadata": { + "name": "amm", + "version": "0.5.3", + "spec": "0.1.0", + "description": "Mercurial Dynamic AMM" + }, + "docs": ["Program for AMM"], + "instructions": [ + { + "name": "add_balance_liquidity", + "docs": ["Deposit tokens to the pool in a balanced ratio."], + "discriminator": [168, 227, 50, 62, 189, 171, 84, 176], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA)"], + "writable": true + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "writable": true, + "relations": ["pool"] + }, + { + "name": "user_pool_lp", + "docs": [ + "user pool lp token account. lp will be burned from this account upon success liquidity removal." + ], + "writable": true + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "a_vault_lp_mint", + "docs": ["LP token mint of vault a"], + "writable": true + }, + { + "name": "b_vault_lp_mint", + "docs": ["LP token mint of vault b"], + "writable": true + }, + { + "name": "a_token_vault", + "docs": ["Token vault account of vault A"], + "writable": true + }, + { + "name": "b_token_vault", + "docs": ["Token vault account of vault B"], + "writable": true + }, + { + "name": "user_a_token", + "docs": [ + "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ], + "writable": true + }, + { + "name": "user_b_token", + "docs": [ + "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ], + "writable": true + }, + { + "name": "user", + "docs": [ + "User account. Must be owner of user_a_token, and user_b_token." + ], + "signer": true + }, + { + "name": "vault_program", + "docs": [ + "Vault program. the pool will deposit/withdraw liquidity from the vault." + ], + "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" + }, + { + "name": "token_program", + "docs": ["Token program."], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "pool_token_amount", + "type": "u64" + }, + { + "name": "maximum_token_a_amount", + "type": "u64" + }, + { + "name": "maximum_token_b_amount", + "type": "u64" + } + ] + }, + { + "name": "add_imbalance_liquidity", + "docs": [ + "Deposit tokens to the pool in an imbalance ratio. Only supported by pool with stable swap curve." + ], + "discriminator": [79, 35, 122, 84, 173, 15, 93, 191], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA)"], + "writable": true + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "writable": true, + "relations": ["pool"] + }, + { + "name": "user_pool_lp", + "docs": [ + "user pool lp token account. lp will be burned from this account upon success liquidity removal." + ], + "writable": true + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "a_vault_lp_mint", + "docs": ["LP token mint of vault a"], + "writable": true + }, + { + "name": "b_vault_lp_mint", + "docs": ["LP token mint of vault b"], + "writable": true + }, + { + "name": "a_token_vault", + "docs": ["Token vault account of vault A"], + "writable": true + }, + { + "name": "b_token_vault", + "docs": ["Token vault account of vault B"], + "writable": true + }, + { + "name": "user_a_token", + "docs": [ + "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ], + "writable": true + }, + { + "name": "user_b_token", + "docs": [ + "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ], + "writable": true + }, + { + "name": "user", + "docs": [ + "User account. Must be owner of user_a_token, and user_b_token." + ], + "signer": true + }, + { + "name": "vault_program", + "docs": [ + "Vault program. the pool will deposit/withdraw liquidity from the vault." + ], + "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" + }, + { + "name": "token_program", + "docs": ["Token program."], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "minimum_pool_token_amount", + "type": "u64" + }, + { + "name": "token_a_amount", + "type": "u64" + }, + { + "name": "token_b_amount", + "type": "u64" + } + ] + }, + { + "name": "bootstrap_liquidity", + "docs": ["Bootstrap the pool when liquidity is depleted."], + "discriminator": [4, 228, 215, 71, 225, 253, 119, 206], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA)"], + "writable": true + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "writable": true, + "relations": ["pool"] + }, + { + "name": "user_pool_lp", + "docs": [ + "user pool lp token account. lp will be burned from this account upon success liquidity removal." + ], + "writable": true + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "a_vault_lp_mint", + "docs": ["LP token mint of vault a"], + "writable": true + }, + { + "name": "b_vault_lp_mint", + "docs": ["LP token mint of vault b"], + "writable": true + }, + { + "name": "a_token_vault", + "docs": ["Token vault account of vault A"], + "writable": true + }, + { + "name": "b_token_vault", + "docs": ["Token vault account of vault B"], + "writable": true + }, + { + "name": "user_a_token", + "docs": [ + "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ], + "writable": true + }, + { + "name": "user_b_token", + "docs": [ + "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ], + "writable": true + }, + { + "name": "user", + "docs": [ + "User account. Must be owner of user_a_token, and user_b_token." + ], + "signer": true + }, + { + "name": "vault_program", + "docs": [ + "Vault program. the pool will deposit/withdraw liquidity from the vault." + ], + "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" + }, + { + "name": "token_program", + "docs": ["Token program."], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "token_a_amount", + "type": "u64" + }, + { + "name": "token_b_amount", + "type": "u64" + } + ] + }, + { + "name": "claim_fee", + "docs": ["Claim fee"], + "discriminator": [169, 32, 79, 137, 136, 232, 70, 137], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account"], + "writable": true, + "relations": ["lock_escrow"] + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "writable": true, + "relations": ["pool"] + }, + { + "name": "lock_escrow", + "docs": ["Lock account"], + "writable": true + }, + { + "name": "owner", + "docs": ["Owner of lock account"], + "writable": true, + "signer": true, + "relations": ["lock_escrow"] + }, + { + "name": "source_tokens", + "docs": ["owner lp token account"], + "writable": true + }, + { + "name": "escrow_vault", + "docs": ["Escrow vault"], + "writable": true, + "relations": ["lock_escrow"] + }, + { + "name": "token_program", + "docs": ["Token program."], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "a_token_vault", + "docs": ["Token vault account of vault A"], + "writable": true + }, + { + "name": "b_token_vault", + "docs": ["Token vault account of vault B"], + "writable": true + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "a_vault_lp_mint", + "docs": ["LP token mint of vault a"], + "writable": true + }, + { + "name": "b_vault_lp_mint", + "docs": ["LP token mint of vault b"], + "writable": true + }, + { + "name": "user_a_token", + "docs": [ + "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ], + "writable": true + }, + { + "name": "user_b_token", + "docs": [ + "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ], + "writable": true + }, + { + "name": "vault_program", + "docs": [ + "Vault program. the pool will deposit/withdraw liquidity from the vault." + ], + "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" + } + ], + "args": [ + { + "name": "max_amount", + "type": "u64" + } + ] + }, + { + "name": "close_config", + "docs": ["Close config"], + "discriminator": [145, 9, 72, 157, 95, 125, 61, 85], + "accounts": [ + { + "name": "config", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "rent_receiver", + "writable": true + } + ], + "args": [] + }, + { + "name": "close_operator_account", + "discriminator": [171, 9, 213, 74, 120, 23, 3, 29], + "accounts": [ + { + "name": "operator", + "writable": true + }, + { + "name": "signer", + "signer": true + }, + { + "name": "rent_receiver", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "create_config", + "docs": ["Create config"], + "discriminator": [201, 207, 243, 114, 75, 111, 47, 189], + "accounts": [ + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [99, 111, 110, 102, 105, 103] + }, + { + "kind": "arg", + "path": "config_parameters.index" + } + ] + } + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "config_parameters", + "type": { + "defined": { + "name": "ConfigParameters" + } + } + } + ] + }, + { + "name": "create_lock_escrow", + "docs": ["Create lock account"], + "discriminator": [54, 87, 165, 19, 69, 227, 218, 224], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account"] + }, + { + "name": "lock_escrow", + "docs": ["Lock account"], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [108, 111, 99, 107, 95, 101, 115, 99, 114, 111, 119] + }, + { + "kind": "account", + "path": "pool" + }, + { + "kind": "account", + "path": "owner" + } + ] + } + }, + { + "name": "owner" + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "relations": ["pool"] + }, + { + "name": "payer", + "docs": ["Payer account"], + "writable": true, + "signer": true + }, + { + "name": "system_program", + "docs": ["System program."], + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "create_mint_metadata", + "docs": ["Create mint metadata account for old pools"], + "discriminator": [13, 70, 168, 41, 250, 100, 148, 90], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account"] + }, + { + "name": "lp_mint", + "docs": ["LP mint account of the pool"], + "relations": ["pool"] + }, + { + "name": "a_vault_lp", + "docs": ["Vault A LP account of the pool"], + "relations": ["pool"] + }, + { + "name": "mint_metadata", + "writable": true + }, + { + "name": "metadata_program", + "address": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" + }, + { + "name": "system_program", + "docs": ["System program."], + "address": "11111111111111111111111111111111" + }, + { + "name": "payer", + "docs": ["Payer"], + "writable": true, + "signer": true + } + ], + "args": [] + }, + { + "name": "create_operator_account", + "discriminator": [221, 64, 246, 149, 240, 153, 229, 163], + "accounts": [ + { + "name": "operator", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [111, 112, 101, 114, 97, 116, 111, 114] + }, + { + "kind": "account", + "path": "whitelisted_address" + } + ] + } + }, + { + "name": "whitelisted_address" + }, + { + "name": "signer", + "signer": true + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "permission", + "type": "u128" + } + ] + }, + { + "name": "enable_or_disable_pool", + "docs": [ + "Enable or disable a pool. A disabled pool allow only remove balanced liquidity operation." + ], + "discriminator": [128, 6, 228, 131, 55, 161, 52, 169], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA)"], + "writable": true + }, + { + "name": "admin", + "docs": ["Admin account. Must be owner of the pool."], + "signer": true + } + ], + "args": [ + { + "name": "enable", + "type": "bool" + } + ] + }, + { + "name": "get_pool_info", + "docs": ["Get the general information of the pool."], + "discriminator": [9, 48, 220, 101, 22, 240, 78, 200], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA)"] + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "relations": ["pool"] + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "relations": ["pool"] + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "relations": ["pool"] + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ], + "relations": ["pool"] + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ], + "relations": ["pool"] + }, + { + "name": "a_vault_lp_mint", + "docs": ["LP token mint of vault a"] + }, + { + "name": "b_vault_lp_mint", + "docs": ["LP token mint of vault b"] + } + ], + "args": [] + }, + { + "name": "initialize_customizable_permissionless_constant_product_pool", + "docs": ["Initialize permissionless pool with customizable params"], + "discriminator": [145, 24, 172, 194, 219, 125, 3, 190], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA address)"], + "writable": true + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [108, 112, 95, 109, 105, 110, 116] + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "token_a_mint", + "docs": ["Token A mint of the pool. Eg: USDT"] + }, + { + "name": "token_b_mint", + "docs": ["Token B mint of the pool. Eg: USDC"] + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ], + "writable": true + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ], + "writable": true + }, + { + "name": "a_token_vault", + "docs": ["Token vault account of vault A"], + "writable": true + }, + { + "name": "b_token_vault", + "docs": ["Token vault account of vault B"], + "writable": true + }, + { + "name": "a_vault_lp_mint", + "docs": ["LP token mint of vault A"], + "writable": true + }, + { + "name": "b_vault_lp_mint", + "docs": ["LP token mint of vault B"], + "writable": true + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "a_vault" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "b_vault" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "payer_token_a", + "docs": [ + "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." + ], + "writable": true + }, + { + "name": "payer_token_b", + "docs": [ + "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." + ], + "writable": true + }, + { + "name": "payer_pool_lp", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "payer" + }, + { + "kind": "const", + "value": [ + 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, + 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, + 245, 133, 126, 255, 0, 169 + ] + }, + { + "kind": "account", + "path": "lp_mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, + 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, + 219, 233, 248, 89 + ] + } + } + }, + { + "name": "protocol_token_a_fee", + "docs": [ + "Protocol fee token account for token A. Used to receive trading fee." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [102, 101, 101] + }, + { + "kind": "account", + "path": "token_a_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "protocol_token_b_fee", + "docs": [ + "Protocol fee token account for token B. Used to receive trading fee." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [102, 101, 101] + }, + { + "kind": "account", + "path": "token_b_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "payer", + "docs": [ + "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." + ], + "writable": true, + "signer": true + }, + { + "name": "rent", + "docs": ["Rent account."], + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "mint_metadata", + "writable": true + }, + { + "name": "metadata_program" + }, + { + "name": "vault_program", + "docs": [ + "Vault program. The pool will deposit/withdraw liquidity from the vault." + ], + "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" + }, + { + "name": "token_program", + "docs": ["Token program."], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "associated_token_program", + "docs": ["Associated token program."], + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "system_program", + "docs": ["System program."], + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "token_a_amount", + "type": "u64" + }, + { + "name": "token_b_amount", + "type": "u64" + }, + { + "name": "params", + "type": { + "defined": { + "name": "CustomizableParams" + } + } + } + ] + }, + { + "name": "initialize_permissioned_pool", + "docs": ["Initialize a new permissioned pool."], + "discriminator": [77, 85, 178, 157, 50, 48, 212, 126], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (arbitrary address)"], + "writable": true, + "signer": true + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [108, 112, 95, 109, 105, 110, 116] + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "token_a_mint", + "docs": ["Token A mint of the pool. Eg: USDT"] + }, + { + "name": "token_b_mint", + "docs": ["Token B mint of the pool. Eg: USDC"] + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ], + "writable": true + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ], + "writable": true + }, + { + "name": "a_vault_lp_mint", + "docs": ["LP token mint of vault A"], + "writable": true + }, + { + "name": "b_vault_lp_mint", + "docs": ["LP token mint of vault B"], + "writable": true + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "a_vault" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "b_vault" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "admin_token_a", + "docs": [ + "Admin token account for pool token A mint. Used to bootstrap the pool with initial liquidity." + ], + "writable": true + }, + { + "name": "admin_token_b", + "docs": [ + "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." + ], + "writable": true + }, + { + "name": "admin_pool_lp", + "docs": [ + "Admin pool LP token account. Used to receive LP during first deposit (initialize pool)", + "Admin pool LP token account. Used to receive LP during first deposit (initialize pool)" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "admin" + }, + { + "kind": "const", + "value": [ + 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, + 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, + 245, 133, 126, 255, 0, 169 + ] + }, + { + "kind": "account", + "path": "lp_mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, + 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, + 219, 233, 248, 89 + ] + } + } + }, + { + "name": "protocol_token_a_fee", + "docs": [ + "Protocol fee token account for token A. Used to receive trading fee." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [102, 101, 101] + }, + { + "kind": "account", + "path": "token_a_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "protocol_token_b_fee", + "docs": [ + "Protocol fee token account for token B. Used to receive trading fee." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [102, 101, 101] + }, + { + "kind": "account", + "path": "token_b_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "admin", + "docs": [ + "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." + ], + "writable": true, + "signer": true + }, + { + "name": "fee_owner" + }, + { + "name": "rent", + "docs": ["Rent account."], + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "mint_metadata", + "writable": true + }, + { + "name": "metadata_program" + }, + { + "name": "vault_program", + "docs": [ + "Vault program. The pool will deposit/withdraw liquidity from the vault." + ], + "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" + }, + { + "name": "token_program", + "docs": ["Token program."], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "associated_token_program", + "docs": ["Associated token program."], + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "system_program", + "docs": ["System program."], + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "curve_type", + "type": { + "defined": { + "name": "CurveType" + } + } + } + ] + }, + { + "name": "initialize_permissionless_constant_product_pool_with_config", + "docs": ["Initialize permissionless pool with config"], + "discriminator": [7, 166, 138, 171, 206, 171, 236, 244], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA address)"], + "writable": true + }, + { + "name": "config" + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [108, 112, 95, 109, 105, 110, 116] + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "token_a_mint", + "docs": ["Token A mint of the pool. Eg: USDT"] + }, + { + "name": "token_b_mint", + "docs": ["Token B mint of the pool. Eg: USDC"] + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ], + "writable": true + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ], + "writable": true + }, + { + "name": "a_token_vault", + "docs": ["Token vault account of vault A"], + "writable": true + }, + { + "name": "b_token_vault", + "docs": ["Token vault account of vault B"], + "writable": true + }, + { + "name": "a_vault_lp_mint", + "docs": ["LP token mint of vault A"], + "writable": true + }, + { + "name": "b_vault_lp_mint", + "docs": ["LP token mint of vault B"], + "writable": true + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "a_vault" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "b_vault" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "payer_token_a", + "docs": [ + "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." + ], + "writable": true + }, + { + "name": "payer_token_b", + "docs": [ + "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." + ], + "writable": true + }, + { + "name": "payer_pool_lp", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "payer" + }, + { + "kind": "const", + "value": [ + 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, + 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, + 245, 133, 126, 255, 0, 169 + ] + }, + { + "kind": "account", + "path": "lp_mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, + 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, + 219, 233, 248, 89 + ] + } + } + }, + { + "name": "protocol_token_a_fee", + "docs": [ + "Protocol fee token account for token A. Used to receive trading fee." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [102, 101, 101] + }, + { + "kind": "account", + "path": "token_a_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "protocol_token_b_fee", + "docs": [ + "Protocol fee token account for token B. Used to receive trading fee." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [102, 101, 101] + }, + { + "kind": "account", + "path": "token_b_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "payer", + "docs": [ + "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." + ], + "writable": true, + "signer": true + }, + { + "name": "rent", + "docs": ["Rent account."], + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "mint_metadata", + "writable": true + }, + { + "name": "metadata_program" + }, + { + "name": "vault_program", + "docs": [ + "Vault program. The pool will deposit/withdraw liquidity from the vault." + ], + "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" + }, + { + "name": "token_program", + "docs": ["Token program."], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "associated_token_program", + "docs": ["Associated token program."], + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "system_program", + "docs": ["System program."], + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "token_a_amount", + "type": "u64" + }, + { + "name": "token_b_amount", + "type": "u64" + } + ] + }, + { + "name": "initialize_permissionless_constant_product_pool_with_config2", + "docs": ["Initialize permissionless pool with config 2"], + "discriminator": [48, 149, 220, 130, 61, 11, 9, 178], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA address)"], + "writable": true + }, + { + "name": "config" + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [108, 112, 95, 109, 105, 110, 116] + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "token_a_mint", + "docs": ["Token A mint of the pool. Eg: USDT"] + }, + { + "name": "token_b_mint", + "docs": ["Token B mint of the pool. Eg: USDC"] + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ], + "writable": true + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ], + "writable": true + }, + { + "name": "a_token_vault", + "docs": ["Token vault account of vault A"], + "writable": true + }, + { + "name": "b_token_vault", + "docs": ["Token vault account of vault B"], + "writable": true + }, + { + "name": "a_vault_lp_mint", + "docs": ["LP token mint of vault A"], + "writable": true + }, + { + "name": "b_vault_lp_mint", + "docs": ["LP token mint of vault B"], + "writable": true + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "a_vault" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "b_vault" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "payer_token_a", + "docs": [ + "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." + ], + "writable": true + }, + { + "name": "payer_token_b", + "docs": [ + "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." + ], + "writable": true + }, + { + "name": "payer_pool_lp", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "payer" + }, + { + "kind": "const", + "value": [ + 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, + 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, + 245, 133, 126, 255, 0, 169 + ] + }, + { + "kind": "account", + "path": "lp_mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, + 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, + 219, 233, 248, 89 + ] + } + } + }, + { + "name": "protocol_token_a_fee", + "docs": [ + "Protocol fee token account for token A. Used to receive trading fee." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [102, 101, 101] + }, + { + "kind": "account", + "path": "token_a_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "protocol_token_b_fee", + "docs": [ + "Protocol fee token account for token B. Used to receive trading fee." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [102, 101, 101] + }, + { + "kind": "account", + "path": "token_b_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "payer", + "docs": [ + "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." + ], + "writable": true, + "signer": true + }, + { + "name": "rent", + "docs": ["Rent account."], + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "mint_metadata", + "writable": true + }, + { + "name": "metadata_program" + }, + { + "name": "vault_program", + "docs": [ + "Vault program. The pool will deposit/withdraw liquidity from the vault." + ], + "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" + }, + { + "name": "token_program", + "docs": ["Token program."], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "associated_token_program", + "docs": ["Associated token program."], + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "system_program", + "docs": ["System program."], + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "token_a_amount", + "type": "u64" + }, + { + "name": "token_b_amount", + "type": "u64" + }, + { + "name": "activation_point", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "initialize_permissionless_pool", + "docs": ["Initialize a new permissionless pool."], + "discriminator": [118, 173, 41, 157, 173, 72, 97, 103], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA address)"], + "writable": true + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [108, 112, 95, 109, 105, 110, 116] + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "token_a_mint", + "docs": ["Token A mint of the pool. Eg: USDT"] + }, + { + "name": "token_b_mint", + "docs": ["Token B mint of the pool. Eg: USDC"] + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ], + "writable": true + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ], + "writable": true + }, + { + "name": "a_token_vault", + "docs": ["Token vault account of vault A"], + "writable": true + }, + { + "name": "b_token_vault", + "docs": ["Token vault account of vault B"], + "writable": true + }, + { + "name": "a_vault_lp_mint", + "docs": ["LP token mint of vault A"], + "writable": true + }, + { + "name": "b_vault_lp_mint", + "docs": ["LP token mint of vault B"], + "writable": true + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "a_vault" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "b_vault" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "payer_token_a", + "docs": [ + "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." + ], + "writable": true + }, + { + "name": "payer_token_b", + "docs": [ + "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." + ], + "writable": true + }, + { + "name": "payer_pool_lp", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "payer" + }, + { + "kind": "const", + "value": [ + 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, + 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, + 245, 133, 126, 255, 0, 169 + ] + }, + { + "kind": "account", + "path": "lp_mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, + 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, + 219, 233, 248, 89 + ] + } + } + }, + { + "name": "protocol_token_a_fee", + "docs": [ + "Protocol fee token account for token A. Used to receive trading fee." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [102, 101, 101] + }, + { + "kind": "account", + "path": "token_a_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "protocol_token_b_fee", + "docs": [ + "Protocol fee token account for token B. Used to receive trading fee." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [102, 101, 101] + }, + { + "kind": "account", + "path": "token_b_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "payer", + "docs": [ + "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." + ], + "writable": true, + "signer": true + }, + { + "name": "fee_owner" + }, + { + "name": "rent", + "docs": ["Rent account."], + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "mint_metadata", + "writable": true + }, + { + "name": "metadata_program" + }, + { + "name": "vault_program", + "docs": [ + "Vault program. The pool will deposit/withdraw liquidity from the vault." + ], + "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" + }, + { + "name": "token_program", + "docs": ["Token program."], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "associated_token_program", + "docs": ["Associated token program."], + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "system_program", + "docs": ["System program."], + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "curve_type", + "type": { + "defined": { + "name": "CurveType" + } + } + }, + { + "name": "token_a_amount", + "type": "u64" + }, + { + "name": "token_b_amount", + "type": "u64" + } + ] + }, + { + "name": "initialize_permissionless_pool_with_fee_tier", + "docs": ["Initialize a new permissionless pool with customized fee tier"], + "discriminator": [6, 135, 68, 147, 229, 82, 169, 113], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA address)"], + "writable": true + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [108, 112, 95, 109, 105, 110, 116] + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "token_a_mint", + "docs": ["Token A mint of the pool. Eg: USDT"] + }, + { + "name": "token_b_mint", + "docs": ["Token B mint of the pool. Eg: USDC"] + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ], + "writable": true + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ], + "writable": true + }, + { + "name": "a_token_vault", + "docs": ["Token vault account of vault A"], + "writable": true + }, + { + "name": "b_token_vault", + "docs": ["Token vault account of vault B"], + "writable": true + }, + { + "name": "a_vault_lp_mint", + "docs": ["LP token mint of vault A"], + "writable": true + }, + { + "name": "b_vault_lp_mint", + "docs": ["LP token mint of vault B"], + "writable": true + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "a_vault" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "b_vault" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "payer_token_a", + "docs": [ + "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." + ], + "writable": true + }, + { + "name": "payer_token_b", + "docs": [ + "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." + ], + "writable": true + }, + { + "name": "payer_pool_lp", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "payer" + }, + { + "kind": "const", + "value": [ + 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, + 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, + 245, 133, 126, 255, 0, 169 + ] + }, + { + "kind": "account", + "path": "lp_mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, + 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, + 219, 233, 248, 89 + ] + } + } + }, + { + "name": "protocol_token_a_fee", + "docs": [ + "Protocol fee token account for token A. Used to receive trading fee." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [102, 101, 101] + }, + { + "kind": "account", + "path": "token_a_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "protocol_token_b_fee", + "docs": [ + "Protocol fee token account for token B. Used to receive trading fee." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [102, 101, 101] + }, + { + "kind": "account", + "path": "token_b_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "payer", + "docs": [ + "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." + ], + "writable": true, + "signer": true + }, + { + "name": "fee_owner" + }, + { + "name": "rent", + "docs": ["Rent account."], + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "mint_metadata", + "writable": true + }, + { + "name": "metadata_program" + }, + { + "name": "vault_program", + "docs": [ + "Vault program. The pool will deposit/withdraw liquidity from the vault." + ], + "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" + }, + { + "name": "token_program", + "docs": ["Token program."], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "associated_token_program", + "docs": ["Associated token program."], + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "system_program", + "docs": ["System program."], + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "curve_type", + "type": { + "defined": { + "name": "CurveType" + } + } + }, + { + "name": "trade_fee_bps", + "type": "u64" + }, + { + "name": "token_a_amount", + "type": "u64" + }, + { + "name": "token_b_amount", + "type": "u64" + } + ] + }, + { + "name": "lock", + "docs": ["Lock Lp token"], + "discriminator": [21, 19, 208, 43, 237, 62, 255, 87], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account"], + "writable": true, + "relations": ["lock_escrow"] + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "relations": ["pool"] + }, + { + "name": "lock_escrow", + "docs": ["Lock account"], + "writable": true + }, + { + "name": "owner", + "docs": ["Can be anyone"], + "writable": true, + "signer": true + }, + { + "name": "source_tokens", + "docs": ["owner lp token account"], + "writable": true + }, + { + "name": "escrow_vault", + "docs": ["Escrow vault"], + "writable": true, + "relations": ["lock_escrow"] + }, + { + "name": "token_program", + "docs": ["Token program."], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ], + "relations": ["pool"] + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ], + "relations": ["pool"] + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "relations": ["pool"] + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "relations": ["pool"] + }, + { + "name": "a_vault_lp_mint", + "docs": ["LP token mint of vault a"] + }, + { + "name": "b_vault_lp_mint", + "docs": ["LP token mint of vault b"] + } + ], + "args": [ + { + "name": "max_amount", + "type": "u64" + } + ] + }, + { + "name": "override_curve_param", + "docs": [ + "Update swap curve parameters. This function do not allow update of curve type. For example: stable swap curve to constant product curve. Only supported by pool with stable swap curve.", + "Only amp is allowed to be override. The other attributes of stable swap curve will be ignored." + ], + "discriminator": [98, 86, 204, 51, 94, 71, 69, 187], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA)"], + "writable": true + }, + { + "name": "admin", + "docs": ["Admin account."], + "signer": true + } + ], + "args": [ + { + "name": "curve_type", + "type": { + "defined": { + "name": "CurveType" + } + } + } + ] + }, + { + "name": "partner_claim_fee", + "docs": ["Partner claim fee"], + "discriminator": [57, 53, 176, 30, 123, 70, 52, 64], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA)"], + "writable": true + }, + { + "name": "a_vault_lp", + "relations": ["pool"] + }, + { + "name": "protocol_token_a_fee", + "writable": true, + "relations": ["pool"] + }, + { + "name": "protocol_token_b_fee", + "writable": true, + "relations": ["pool"] + }, + { + "name": "partner_token_a", + "writable": true + }, + { + "name": "partner_token_b", + "writable": true + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "partner_authority", + "signer": true + } + ], + "args": [ + { + "name": "max_amount_a", + "type": "u64" + }, + { + "name": "max_amount_b", + "type": "u64" + } + ] + }, + { + "name": "remove_balance_liquidity", + "docs": [ + "Withdraw tokens from the pool in a balanced ratio. User will still able to withdraw from pool even the pool is disabled. This allow user to exit their liquidity when there's some unforeseen event happen." + ], + "discriminator": [133, 109, 44, 179, 56, 238, 114, 33], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA)"], + "writable": true + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "writable": true, + "relations": ["pool"] + }, + { + "name": "user_pool_lp", + "docs": [ + "user pool lp token account. lp will be burned from this account upon success liquidity removal." + ], + "writable": true + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "a_vault_lp_mint", + "docs": ["LP token mint of vault a"], + "writable": true + }, + { + "name": "b_vault_lp_mint", + "docs": ["LP token mint of vault b"], + "writable": true + }, + { + "name": "a_token_vault", + "docs": ["Token vault account of vault A"], + "writable": true + }, + { + "name": "b_token_vault", + "docs": ["Token vault account of vault B"], + "writable": true + }, + { + "name": "user_a_token", + "docs": [ + "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ], + "writable": true + }, + { + "name": "user_b_token", + "docs": [ + "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ], + "writable": true + }, + { + "name": "user", + "docs": [ + "User account. Must be owner of user_a_token, and user_b_token." + ], + "signer": true + }, + { + "name": "vault_program", + "docs": [ + "Vault program. the pool will deposit/withdraw liquidity from the vault." + ], + "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" + }, + { + "name": "token_program", + "docs": ["Token program."], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "pool_token_amount", + "type": "u64" + }, + { + "name": "minimum_a_token_out", + "type": "u64" + }, + { + "name": "minimum_b_token_out", + "type": "u64" + } + ] + }, + { + "name": "remove_liquidity_single_side", + "docs": [ + "Withdraw only single token from the pool. Only supported by pool with stable swap curve." + ], + "discriminator": [84, 84, 177, 66, 254, 185, 10, 251], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA)"], + "writable": true + }, + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "writable": true, + "relations": ["pool"] + }, + { + "name": "user_pool_lp", + "docs": [ + "User pool lp token account. LP will be burned from this account upon success liquidity removal." + ], + "writable": true + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "a_vault_lp_mint", + "docs": ["LP token mint of vault A"], + "writable": true + }, + { + "name": "b_vault_lp_mint", + "docs": ["LP token mint of vault B"], + "writable": true + }, + { + "name": "a_token_vault", + "docs": ["Token vault account of vault A"], + "writable": true + }, + { + "name": "b_token_vault", + "docs": ["Token vault account of vault B"], + "writable": true + }, + { + "name": "user_destination_token", + "docs": [ + "User token account to receive token upon success liquidity removal." + ], + "writable": true + }, + { + "name": "user", + "docs": ["User account. Must be owner of the user_pool_lp account."], + "signer": true + }, + { + "name": "vault_program", + "docs": [ + "Vault program. The pool will deposit/withdraw liquidity from the vault." + ], + "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" + }, + { + "name": "token_program", + "docs": ["Token program."], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "pool_token_amount", + "type": "u64" + }, + { + "name": "minimum_out_amount", + "type": "u64" + } + ] + }, + { + "name": "set_pool_fees", + "docs": ["Update trading fee charged for liquidity provider, and admin."], + "discriminator": [102, 44, 158, 54, 205, 37, 126, 78], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA)"], + "writable": true + }, + { + "name": "fee_operator", + "docs": ["Fee operator account"], + "signer": true + } + ], + "args": [ + { + "name": "fees", + "type": { + "defined": { + "name": "PoolFees" + } + } + }, + { + "name": "new_partner_fee_numerator", + "type": "u64" + } + ] + }, + { + "name": "set_whitelisted_vault", + "docs": ["Set whitelisted vault"], + "discriminator": [12, 148, 94, 42, 55, 57, 83, 247], + "accounts": [ + { + "name": "pool", + "writable": true + }, + { + "name": "admin", + "signer": true + } + ], + "args": [ + { + "name": "whitelisted_vault", + "type": "pubkey" + } + ] + }, + { + "name": "swap", + "docs": [ + "Swap token A to B, or vice versa. An amount of trading fee will be charged for liquidity provider, and the admin of the pool." + ], + "discriminator": [248, 198, 158, 145, 225, 117, 135, 200], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA)"], + "writable": true + }, + { + "name": "user_source_token", + "docs": [ + "User token account. Token from this account will be transfer into the vault by the pool in exchange for another token of the pool." + ], + "writable": true + }, + { + "name": "user_destination_token", + "docs": [ + "User token account. The exchanged token will be transfer into this account from the pool." + ], + "writable": true + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "a_token_vault", + "docs": ["Token vault account of vault A"], + "writable": true + }, + { + "name": "b_token_vault", + "docs": ["Token vault account of vault B"], + "writable": true + }, + { + "name": "a_vault_lp_mint", + "docs": ["Lp token mint of vault a"], + "writable": true + }, + { + "name": "b_vault_lp_mint", + "docs": ["Lp token mint of vault b"], + "writable": true + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "writable": true, + "relations": ["pool"] + }, + { + "name": "protocol_token_fee", + "docs": [ + "Protocol fee token account. Used to receive trading fee. It's mint field must matched with user_source_token mint field." + ], + "writable": true + }, + { + "name": "user", + "docs": ["User account. Must be owner of user_source_token."], + "signer": true + }, + { + "name": "vault_program", + "docs": [ + "Vault program. the pool will deposit/withdraw liquidity from the vault." + ], + "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi" + }, + { + "name": "token_program", + "docs": ["Token program."], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "in_amount", + "type": "u64" + }, + { + "name": "minimum_out_amount", + "type": "u64" + } + ] + }, + { + "name": "update_activation_point", + "docs": ["Update activation slot"], + "discriminator": [150, 62, 125, 219, 171, 220, 26, 237], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA)"], + "writable": true + }, + { + "name": "admin", + "docs": ["Admin account."], + "signer": true + } + ], + "args": [ + { + "name": "new_activation_point", + "type": "u64" + } + ] + }, + { + "name": "withdraw_protocol_fees", + "docs": ["Withdraw protocol fee"], + "discriminator": [11, 68, 165, 98, 18, 208, 134, 73], + "accounts": [ + { + "name": "pool", + "docs": ["Pool account (PDA)"] + }, + { + "name": "a_vault_lp", + "relations": ["pool"] + }, + { + "name": "protocol_token_a_fee", + "writable": true, + "relations": ["pool"] + }, + { + "name": "protocol_token_b_fee", + "writable": true, + "relations": ["pool"] + }, + { + "name": "treasury_token_a", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 48, 9, 89, 123, 106, 114, 131, 251, 50, 173, 254, 250, 10, 80, + 160, 84, 143, 100, 81, 249, 134, 112, 30, 213, 50, 166, 239, + 78, 53, 175, 188, 85 + ] + }, + { + "kind": "const", + "value": [ + 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, + 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, + 245, 133, 126, 255, 0, 169 + ] + }, + { + "kind": "account", + "path": "protocol_token_a_fee.mint", + "account": "TokenAccount" + } + ], + "program": { + "kind": "const", + "value": [ + 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, + 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, + 219, 233, 248, 89 + ] + } + } + }, + { + "name": "treasury_token_b", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 48, 9, 89, 123, 106, 114, 131, 251, 50, 173, 254, 250, 10, 80, + 160, 84, 143, 100, 81, 249, 134, 112, 30, 213, 50, 166, 239, + 78, 53, 175, 188, 85 + ] + }, + { + "kind": "const", + "value": [ + 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, + 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, + 245, 133, 126, 255, 0, 169 + ] + }, + { + "kind": "account", + "path": "protocol_token_b_fee.mint", + "account": "TokenAccount" + } + ], + "program": { + "kind": "const", + "value": [ + 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, + 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, + 219, 233, 248, 89 + ] + } + } + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [] + }, + { + "name": "zap_protocol_fee", + "discriminator": [213, 155, 187, 34, 56, 182, 91, 240], + "accounts": [ + { + "name": "pool" + }, + { + "name": "a_vault_lp", + "relations": ["pool"] + }, + { + "name": "protocol_token_fee", + "writable": true + }, + { + "name": "token_mint" + }, + { + "name": "receiver_token", + "writable": true + }, + { + "name": "operator", + "docs": ["zap claim fee operator"] + }, + { + "name": "signer", + "docs": ["Operator"], + "signer": true + }, + { + "name": "token_program", + "docs": ["Token program"], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "sysvar_instructions", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "max_amount", + "type": "u64" + } + ] + } + ], + "accounts": [ + { + "name": "Config", + "discriminator": [155, 12, 170, 224, 30, 250, 204, 130] + }, + { + "name": "LockEscrow", + "discriminator": [190, 106, 121, 6, 200, 182, 21, 75] + }, + { + "name": "Operator", + "discriminator": [219, 31, 188, 145, 69, 139, 204, 117] + }, + { + "name": "Pool", + "discriminator": [241, 154, 109, 4, 17, 177, 109, 188] + }, + { + "name": "Vault", + "discriminator": [211, 8, 232, 43, 2, 152, 117, 119] + } + ], + "events": [ + { + "name": "AddLiquidity", + "discriminator": [31, 94, 125, 90, 227, 52, 61, 186] + }, + { + "name": "BootstrapLiquidity", + "discriminator": [121, 127, 38, 136, 92, 55, 14, 247] + }, + { + "name": "ClaimFee", + "discriminator": [75, 122, 154, 48, 140, 74, 123, 163] + }, + { + "name": "CloseConfig", + "discriminator": [249, 181, 108, 89, 4, 150, 90, 174] + }, + { + "name": "CreateConfig", + "discriminator": [199, 152, 10, 19, 39, 39, 157, 104] + }, + { + "name": "CreateLockEscrow", + "discriminator": [74, 94, 106, 141, 49, 17, 98, 109] + }, + { + "name": "Lock", + "discriminator": [220, 183, 67, 215, 153, 207, 56, 234] + }, + { + "name": "MigrateFeeAccount", + "discriminator": [223, 234, 232, 26, 252, 105, 180, 125] + }, + { + "name": "OverrideCurveParam", + "discriminator": [247, 20, 165, 248, 75, 5, 54, 246] + }, + { + "name": "PartnerClaimFees", + "discriminator": [135, 131, 10, 94, 119, 209, 202, 48] + }, + { + "name": "PoolCreated", + "discriminator": [202, 44, 41, 88, 104, 220, 157, 82] + }, + { + "name": "PoolEnabled", + "discriminator": [2, 151, 18, 83, 204, 134, 92, 191] + }, + { + "name": "PoolInfo", + "discriminator": [207, 20, 87, 97, 251, 212, 234, 45] + }, + { + "name": "RemoveLiquidity", + "discriminator": [116, 244, 97, 232, 103, 31, 152, 58] + }, + { + "name": "SetPoolFees", + "discriminator": [245, 26, 198, 164, 88, 18, 75, 9] + }, + { + "name": "Swap", + "discriminator": [81, 108, 227, 190, 205, 208, 10, 196] + }, + { + "name": "TransferAdmin", + "discriminator": [228, 169, 131, 244, 61, 56, 65, 254] + }, + { + "name": "WithdrawProtocolFees", + "discriminator": [30, 240, 207, 196, 139, 239, 79, 28] + } + ], + "errors": [ + { + "code": 6000, + "name": "MathOverflow", + "msg": "Math operation overflow" + }, + { + "code": 6001, + "name": "InvalidFee", + "msg": "Invalid fee setup" + }, + { + "code": 6002, + "name": "InvalidInvariant", + "msg": "Invalid invariant d" + }, + { + "code": 6003, + "name": "FeeCalculationFailure", + "msg": "Fee calculation failure" + }, + { + "code": 6004, + "name": "ExceededSlippage", + "msg": "Exceeded slippage tolerance" + }, + { + "code": 6005, + "name": "InvalidCalculation", + "msg": "Invalid curve calculation" + }, + { + "code": 6006, + "name": "ZeroTradingTokens", + "msg": "Given pool token amount results in zero trading tokens" + }, + { + "code": 6007, + "name": "ConversionError", + "msg": "Math conversion overflow" + }, + { + "code": 6008, + "name": "FaultyLpMint", + "msg": "LP mint authority must be 'A' vault lp, without freeze authority, and 0 supply" + }, + { + "code": 6009, + "name": "MismatchedTokenMint", + "msg": "Token mint mismatched" + }, + { + "code": 6010, + "name": "MismatchedLpMint", + "msg": "LP mint mismatched" + }, + { + "code": 6011, + "name": "MismatchedOwner", + "msg": "Invalid lp token owner" + }, + { + "code": 6012, + "name": "InvalidVaultAccount", + "msg": "Invalid vault account" + }, + { + "code": 6013, + "name": "InvalidVaultLpAccount", + "msg": "Invalid vault lp account" + }, + { + "code": 6014, + "name": "InvalidPoolLpMintAccount", + "msg": "Invalid pool lp mint account" + }, + { + "code": 6015, + "name": "PoolDisabled", + "msg": "Pool disabled" + }, + { + "code": 6016, + "name": "InvalidAdminAccount", + "msg": "Invalid admin account" + }, + { + "code": 6017, + "name": "InvalidProtocolFeeAccount", + "msg": "Invalid protocol fee account" + }, + { + "code": 6018, + "name": "SameAdminAccount", + "msg": "Same admin account" + }, + { + "code": 6019, + "name": "IdenticalSourceDestination", + "msg": "Identical user source and destination token account" + }, + { + "code": 6020, + "name": "ApyCalculationError", + "msg": "Apy calculation error" + }, + { + "code": 6021, + "name": "InsufficientSnapshot", + "msg": "Insufficient virtual price snapshot" + }, + { + "code": 6022, + "name": "NonUpdatableCurve", + "msg": "Current curve is non-updatable" + }, + { + "code": 6023, + "name": "MisMatchedCurve", + "msg": "New curve is mismatched with old curve" + }, + { + "code": 6024, + "name": "InvalidAmplification", + "msg": "Amplification is invalid" + }, + { + "code": 6025, + "name": "UnsupportedOperation", + "msg": "Operation is not supported" + }, + { + "code": 6026, + "name": "ExceedMaxAChanges", + "msg": "Exceed max amplification changes" + }, + { + "code": 6027, + "name": "InvalidRemainingAccountsLen", + "msg": "Invalid remaining accounts length" + }, + { + "code": 6028, + "name": "InvalidRemainingAccounts", + "msg": "Invalid remaining account" + }, + { + "code": 6029, + "name": "MismatchedDepegMint", + "msg": "Token mint B doesn't matches depeg type token mint" + }, + { + "code": 6030, + "name": "InvalidApyAccount", + "msg": "Invalid APY account" + }, + { + "code": 6031, + "name": "InvalidTokenMultiplier", + "msg": "Invalid token multiplier" + }, + { + "code": 6032, + "name": "InvalidDepegInformation", + "msg": "Invalid depeg information" + }, + { + "code": 6033, + "name": "UpdateTimeConstraint", + "msg": "Update time constraint violated" + }, + { + "code": 6034, + "name": "ExceedMaxFeeBps", + "msg": "Exceeded max fee bps" + }, + { + "code": 6035, + "name": "InvalidAdmin", + "msg": "Invalid admin" + }, + { + "code": 6036, + "name": "PoolIsNotPermissioned", + "msg": "Pool is not permissioned" + }, + { + "code": 6037, + "name": "InvalidDepositAmount", + "msg": "Invalid deposit amount" + }, + { + "code": 6038, + "name": "InvalidFeeOwner", + "msg": "Invalid fee owner" + }, + { + "code": 6039, + "name": "NonDepletedPool", + "msg": "Pool is not depleted" + }, + { + "code": 6040, + "name": "AmountNotPeg", + "msg": "Token amount is not 1:1" + }, + { + "code": 6041, + "name": "AmountIsZero", + "msg": "Amount is zero" + }, + { + "code": 6042, + "name": "TypeCastFailed", + "msg": "Type cast error" + }, + { + "code": 6043, + "name": "AmountIsNotEnough", + "msg": "Amount is not enough" + }, + { + "code": 6044, + "name": "InvalidActivationDuration", + "msg": "Invalid activation duration" + }, + { + "code": 6045, + "name": "PoolIsNotLaunchPool", + "msg": "Pool is not launch pool" + }, + { + "code": 6046, + "name": "UnableToModifyActivationPoint", + "msg": "Unable to modify activation point" + }, + { + "code": 6047, + "name": "InvalidAuthorityToCreateThePool", + "msg": "Invalid authority to create the pool" + }, + { + "code": 6048, + "name": "InvalidActivationType", + "msg": "Invalid activation type" + }, + { + "code": 6049, + "name": "InvalidActivationPoint", + "msg": "Invalid activation point" + }, + { + "code": 6050, + "name": "PreActivationSwapStarted", + "msg": "Pre activation swap window started" + }, + { + "code": 6051, + "name": "InvalidPoolType", + "msg": "Invalid pool type" + }, + { + "code": 6052, + "name": "InvalidQuoteMint", + "msg": "Quote token must be SOL,USDC" + }, + { + "code": 6053, + "name": "InvalidTokenMetadataProgram", + "msg": "Invalid token metadata program" + }, + { + "code": 6054, + "name": "InvalidPermission", + "msg": "Invalid permission" + }, + { + "code": 6055, + "name": "InvalidZapOutParameters", + "msg": "Invalid zap out parameters" + }, + { + "code": 6056, + "name": "IncorrectATA", + "msg": "Incorrect ATA" + }, + { + "code": 6057, + "name": "InvalidWithdrawProtocolFeeZapAccounts", + "msg": "Invalid withdraw protocol fee zap accounts" + }, + { + "code": 6058, + "name": "MintRestrictedFromZap", + "msg": "SOL,USDC protocol fee cannot be withdrawn via zap" + }, + { + "code": 6059, + "name": "CpiDisabled", + "msg": "CPI disabled" + }, + { + "code": 6060, + "name": "MissingZapOutInstruction", + "msg": "Missing zap out instruction" + }, + { + "code": 6061, + "name": "InvalidZapAccounts", + "msg": "Invalid zap accounts" + } + ], + "types": [ + { + "name": "AddLiquidity", + "docs": ["Add liquidity event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "lp_mint_amount", + "docs": ["LP amount user received upon add liquidity."], + "type": "u64" + }, + { + "name": "token_a_amount", + "docs": ["Amount of token A user deposited."], + "type": "u64" + }, + { + "name": "token_b_amount", + "docs": ["Amount of token B user deposited."], + "type": "u64" + } + ] + } + }, + { + "name": "BootstrapLiquidity", + "docs": ["Bootstrap liquidity event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "lp_mint_amount", + "docs": ["LP amount user received upon add liquidity."], + "type": "u64" + }, + { + "name": "token_a_amount", + "docs": ["Amount of token A user deposited."], + "type": "u64" + }, + { + "name": "token_b_amount", + "docs": ["Amount of token B user deposited."], + "type": "u64" + }, + { + "name": "pool", + "docs": ["Pool address"], + "type": "pubkey" + } + ] + } + }, + { + "name": "Bootstrapping", + "type": { + "kind": "struct", + "fields": [ + { + "name": "activation_point", + "docs": ["Activation point, can be slot or timestamp"], + "type": "u64" + }, + { + "name": "whitelisted_vault", + "docs": [ + "Whitelisted vault to be able to buy pool before activation_point" + ], + "type": "pubkey" + }, + { + "name": "pool_creator", + "docs": [ + "Need to store pool creator in lauch pool, so they can modify liquidity before activation_point" + ], + "type": "pubkey" + }, + { + "name": "activation_type", + "docs": ["Activation type, 0 means by slot, 1 means by timestamp"], + "type": "u8" + } + ] + } + }, + { + "name": "ClaimFee", + "docs": ["Claim fee"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "docs": ["Pool address"], + "type": "pubkey" + }, + { + "name": "owner", + "docs": ["Owner of lock escrow"], + "type": "pubkey" + }, + { + "name": "amount", + "docs": ["Lp amount"], + "type": "u64" + }, + { + "name": "a_fee", + "docs": ["A fee"], + "type": "u64" + }, + { + "name": "b_fee", + "docs": ["B fee"], + "type": "u64" + } + ] + } + }, + { + "name": "CloseConfig", + "docs": ["Close config"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "config", + "docs": ["Config pubkey"], + "type": "pubkey" + } + ] + } + }, + { + "name": "Config", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool_fees", + "type": { + "defined": { + "name": "PoolFees" + } + } + }, + { + "name": "activation_duration", + "type": "u64" + }, + { + "name": "vault_config_key", + "type": "pubkey" + }, + { + "name": "pool_creator_authority", + "docs": [ + "Only pool_creator_authority can use the current config to initialize new pool. When it's Pubkey::default, it's a public config." + ], + "type": "pubkey" + }, + { + "name": "activation_type", + "docs": ["Activation type"], + "type": "u8" + }, + { + "name": "partner_fee_numerator", + "type": "u64" + }, + { + "name": "_padding", + "type": { + "array": ["u8", 219] + } + } + ] + } + }, + { + "name": "ConfigParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "trade_fee_numerator", + "type": "u64" + }, + { + "name": "protocol_trade_fee_numerator", + "type": "u64" + }, + { + "name": "activation_duration", + "type": "u64" + }, + { + "name": "vault_config_key", + "type": "pubkey" + }, + { + "name": "pool_creator_authority", + "type": "pubkey" + }, + { + "name": "activation_type", + "type": "u8" + }, + { + "name": "index", + "type": "u64" + }, + { + "name": "partner_fee_numerator", + "type": "u64" + } + ] + } + }, + { + "name": "CreateConfig", + "docs": ["Create config"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "trade_fee_numerator", + "docs": ["New trade fee numerator"], + "type": "u64" + }, + { + "name": "protocol_trade_fee_numerator", + "docs": ["New protocol fee numerator"], + "type": "u64" + }, + { + "name": "config", + "docs": ["Config pubkey"], + "type": "pubkey" + } + ] + } + }, + { + "name": "CreateLockEscrow", + "docs": ["Create lock escrow"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "docs": ["Pool address"], + "type": "pubkey" + }, + { + "name": "owner", + "docs": ["Owner of lock escrow"], + "type": "pubkey" + } + ] + } + }, + { + "name": "CurveType", + "docs": ["Type of the swap curve"], + "type": { + "kind": "enum", + "variants": [ + { + "name": "ConstantProduct" + }, + { + "name": "Stable", + "fields": [ + { + "name": "amp", + "docs": ["Amplification coefficient"], + "type": "u64" + }, + { + "name": "token_multiplier", + "docs": [ + "Multiplier for the pool token. Used to normalized token with different decimal into the same precision." + ], + "type": { + "defined": { + "name": "TokenMultiplier" + } + } + }, + { + "name": "depeg", + "docs": [ + "Depeg pool information. Contains functions to allow token amount to be repeg using stake / interest bearing token virtual price" + ], + "type": { + "defined": { + "name": "Depeg" + } + } + }, + { + "name": "last_amp_updated_timestamp", + "docs": [ + "The last amp updated timestamp. Used to prevent update_curve_info called infinitely many times within a short period" + ], + "type": "u64" + } + ] + } + ] + } + }, + { + "name": "CustomizableParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "trade_fee_numerator", + "docs": ["Trading fee."], + "type": "u32" + }, + { + "name": "activation_point", + "docs": ["The pool start trading."], + "type": { + "option": "u64" + } + }, + { + "name": "has_alpha_vault", + "docs": ["Whether the pool support alpha vault"], + "type": "bool" + }, + { + "name": "activation_type", + "docs": ["Activation type"], + "type": "u8" + }, + { + "name": "padding", + "docs": ["Padding"], + "type": { + "array": ["u8", 90] + } + } + ] + } + }, + { + "name": "Depeg", + "docs": ["Contains information for depeg pool"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "base_virtual_price", + "docs": ["The virtual price of staking / interest bearing token"], + "type": "u64" + }, + { + "name": "base_cache_updated", + "docs": ["The last time base_virtual_price is updated"], + "type": "u64" + }, + { + "name": "depeg_type", + "docs": ["Type of the depeg pool"], + "type": { + "defined": { + "name": "DepegType" + } + } + } + ] + } + }, + { + "name": "DepegType", + "docs": ["Type of depeg pool"], + "type": { + "kind": "enum", + "variants": [ + { + "name": "None" + }, + { + "name": "Marinade" + }, + { + "name": "Lido" + }, + { + "name": "SplStake" + } + ] + } + }, + { + "name": "Lock", + "docs": ["Lock"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "docs": ["Pool address"], + "type": "pubkey" + }, + { + "name": "owner", + "docs": ["Owner of lock escrow"], + "type": "pubkey" + }, + { + "name": "amount", + "docs": ["Locked amount"], + "type": "u64" + } + ] + } + }, + { + "name": "LockEscrow", + "docs": ["State of lock escrow account"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "docs": ["Pool address"], + "type": "pubkey" + }, + { + "name": "owner", + "docs": ["Owner address"], + "type": "pubkey" + }, + { + "name": "escrow_vault", + "docs": ["Vault address, store the lock user lock"], + "type": "pubkey" + }, + { + "name": "bump", + "docs": ["bump, used to sign"], + "type": "u8" + }, + { + "name": "total_locked_amount", + "docs": ["Total locked amount"], + "type": "u64" + }, + { + "name": "lp_per_token", + "docs": ["Lp per token, virtual price of lp token"], + "type": "u128" + }, + { + "name": "unclaimed_fee_pending", + "docs": ["Unclaimed fee pending"], + "type": "u64" + }, + { + "name": "a_fee", + "docs": ["Total a fee claimed so far"], + "type": "u64" + }, + { + "name": "b_fee", + "docs": ["Total b fee claimed so far"], + "type": "u64" + } + ] + } + }, + { + "name": "LockedProfitTracker", + "docs": ["LockedProfitTracker struct"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "last_updated_locked_profit", + "docs": ["The total locked profit from the last report"], + "type": "u64" + }, + { + "name": "last_report", + "docs": ["The last timestamp (in seconds) rebalancing"], + "type": "u64" + }, + { + "name": "locked_profit_degradation", + "docs": ["Rate per second of degradation"], + "type": "u64" + } + ] + } + }, + { + "name": "MigrateFeeAccount", + "docs": ["Migrate fee account event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "docs": ["Pool address"], + "type": "pubkey" + }, + { + "name": "new_admin_token_a_fee", + "docs": ["New admin token a fee"], + "type": "pubkey" + }, + { + "name": "new_admin_token_b_fee", + "docs": ["New admin token b fee"], + "type": "pubkey" + }, + { + "name": "token_a_amount", + "docs": ["Transfer token a fee amount"], + "type": "u64" + }, + { + "name": "token_b_amount", + "docs": ["Transfer token b fee amount"], + "type": "u64" + } + ] + } + }, + { + "name": "Operator", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "whitelisted_address", + "type": "pubkey" + }, + { + "name": "permission", + "type": "u128" + }, + { + "name": "padding", + "type": { + "array": ["u64", 2] + } + } + ] + } + }, + { + "name": "OverrideCurveParam", + "docs": ["Override curve param event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_amp", + "docs": ["The new amplification for stable curve"], + "type": "u64" + }, + { + "name": "updated_timestamp", + "docs": ["Updated timestamp"], + "type": "u64" + }, + { + "name": "pool", + "docs": ["Pool address"], + "type": "pubkey" + } + ] + } + }, + { + "name": "Padding", + "docs": ["Padding for future pool fields"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "padding_0", + "docs": ["Padding 0"], + "type": { + "array": ["u8", 6] + } + }, + { + "name": "padding_1", + "docs": ["Padding 1"], + "type": { + "array": ["u64", 21] + } + }, + { + "name": "padding_2", + "docs": ["Padding 2"], + "type": { + "array": ["u64", 21] + } + } + ] + } + }, + { + "name": "PartnerClaimFees", + "docs": ["Partner claim fees"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "docs": ["Pool address"], + "type": "pubkey" + }, + { + "name": "fee_a", + "docs": ["Fee B"], + "type": "u64" + }, + { + "name": "fee_b", + "docs": ["Fee B"], + "type": "u64" + }, + { + "name": "partner", + "docs": ["Partner"], + "type": "pubkey" + } + ] + } + }, + { + "name": "PartnerInfo", + "type": { + "kind": "struct", + "fields": [ + { + "name": "fee_numerator", + "type": "u64" + }, + { + "name": "partner_authority", + "type": "pubkey" + }, + { + "name": "pending_fee_a", + "type": "u64" + }, + { + "name": "pending_fee_b", + "type": "u64" + } + ] + } + }, + { + "name": "Pool", + "docs": ["State of pool account"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "type": "pubkey" + }, + { + "name": "token_a_mint", + "docs": ["Token A mint of the pool. Eg: USDT"], + "type": "pubkey" + }, + { + "name": "token_b_mint", + "docs": ["Token B mint of the pool. Eg: USDC"], + "type": "pubkey" + }, + { + "name": "a_vault", + "docs": [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ], + "type": "pubkey" + }, + { + "name": "b_vault", + "docs": [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ], + "type": "pubkey" + }, + { + "name": "a_vault_lp", + "docs": [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "type": "pubkey" + }, + { + "name": "b_vault_lp", + "docs": [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ], + "type": "pubkey" + }, + { + "name": "a_vault_lp_bump", + "docs": ["\"A\" vault lp bump. Used to create signer seeds."], + "type": "u8" + }, + { + "name": "enabled", + "docs": [ + "Flag to determine whether the pool is enabled, or disabled." + ], + "type": "bool" + }, + { + "name": "protocol_token_a_fee", + "docs": [ + "Protocol fee token account for token A. Used to receive trading fee." + ], + "type": "pubkey" + }, + { + "name": "protocol_token_b_fee", + "docs": [ + "Protocol fee token account for token B. Used to receive trading fee." + ], + "type": "pubkey" + }, + { + "name": "fee_last_updated_at", + "docs": ["Fee last updated timestamp"], + "type": "u64" + }, + { + "name": "_padding0", + "type": { + "array": ["u8", 24] + } + }, + { + "name": "fees", + "docs": ["Store the fee charges setting."], + "type": { + "defined": { + "name": "PoolFees" + } + } + }, + { + "name": "pool_type", + "docs": ["Pool type"], + "type": { + "defined": { + "name": "PoolType" + } + } + }, + { + "name": "stake", + "docs": ["Stake pubkey of SPL stake pool"], + "type": "pubkey" + }, + { + "name": "total_locked_lp", + "docs": ["Total locked lp token"], + "type": "u64" + }, + { + "name": "bootstrapping", + "docs": ["bootstrapping config"], + "type": { + "defined": { + "name": "Bootstrapping" + } + } + }, + { + "name": "partner_info", + "type": { + "defined": { + "name": "PartnerInfo" + } + } + }, + { + "name": "padding", + "docs": ["Padding for future pool field"], + "type": { + "defined": { + "name": "Padding" + } + } + }, + { + "name": "curve_type", + "docs": ["The type of the swap curve supported by the pool."], + "type": { + "defined": { + "name": "CurveType" + } + } + } + ] + } + }, + { + "name": "PoolCreated", + "docs": ["New pool created event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "lp_mint", + "docs": ["LP token mint of the pool"], + "type": "pubkey" + }, + { + "name": "token_a_mint", + "docs": ["Token A mint of the pool. Eg: USDT"], + "type": "pubkey" + }, + { + "name": "token_b_mint", + "docs": ["Token B mint of the pool. Eg: USDC"], + "type": "pubkey" + }, + { + "name": "pool_type", + "docs": ["Pool type"], + "type": { + "defined": { + "name": "PoolType" + } + } + }, + { + "name": "pool", + "docs": ["Pool address"], + "type": "pubkey" + } + ] + } + }, + { + "name": "PoolEnabled", + "docs": ["Pool enabled state change event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "docs": ["Pool address"], + "type": "pubkey" + }, + { + "name": "enabled", + "docs": ["Pool enabled state"], + "type": "bool" + } + ] + } + }, + { + "name": "PoolFees", + "docs": ["Information regarding fee charges"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "trade_fee_numerator", + "docs": [ + "Trade fees are extra token amounts that are held inside the token", + "accounts during a trade, making the value of liquidity tokens rise.", + "Trade fee numerator" + ], + "type": "u64" + }, + { + "name": "trade_fee_denominator", + "docs": ["Trade fee denominator"], + "type": "u64" + }, + { + "name": "protocol_trade_fee_numerator", + "docs": [ + "Protocol trading fees are extra token amounts that are held inside the token", + "accounts during a trade, with the equivalent in pool tokens minted to", + "the protocol of the program.", + "Protocol trade fee numerator" + ], + "type": "u64" + }, + { + "name": "protocol_trade_fee_denominator", + "docs": ["Protocol trade fee denominator"], + "type": "u64" + } + ] + } + }, + { + "name": "PoolInfo", + "docs": ["Pool info event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "token_a_amount", + "docs": ["Total token A amount in the pool"], + "type": "u64" + }, + { + "name": "token_b_amount", + "docs": ["Total token B amount in the pool"], + "type": "u64" + }, + { + "name": "virtual_price", + "docs": ["Current virtual price"], + "type": "f64" + }, + { + "name": "current_timestamp", + "docs": ["Current unix timestamp"], + "type": "u64" + } + ] + } + }, + { + "name": "PoolType", + "docs": ["Pool type"], + "type": { + "kind": "enum", + "variants": [ + { + "name": "Permissioned" + }, + { + "name": "Permissionless" + } + ] + } + }, + { + "name": "RemoveLiquidity", + "docs": ["Remove liquidity event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "lp_unmint_amount", + "docs": ["LP amount burned from user upon add remove liquidity."], + "type": "u64" + }, + { + "name": "token_a_out_amount", + "docs": ["Amount of token A user received."], + "type": "u64" + }, + { + "name": "token_b_out_amount", + "docs": ["Amount of token B user received."], + "type": "u64" + } + ] + } + }, + { + "name": "SetPoolFees", + "docs": ["Set pool fees event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "trade_fee_numerator", + "docs": ["New trade fee numerator"], + "type": "u64" + }, + { + "name": "trade_fee_denominator", + "docs": ["New trade fee denominator"], + "type": "u64" + }, + { + "name": "protocol_trade_fee_numerator", + "docs": ["New protocol fee numerator"], + "type": "u64" + }, + { + "name": "protocol_trade_fee_denominator", + "docs": ["New protocol fee denominator"], + "type": "u64" + }, + { + "name": "pool", + "docs": ["Pool address"], + "type": "pubkey" + } + ] + } + }, + { + "name": "Swap", + "docs": ["Swap event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "in_amount", + "docs": [ + "Token amount user deposited to the pool for token exchange." + ], + "type": "u64" + }, + { + "name": "out_amount", + "docs": ["Token amount user received from the pool."], + "type": "u64" + }, + { + "name": "trade_fee", + "docs": ["Trading fee charged for liquidity provider."], + "type": "u64" + }, + { + "name": "protocol_fee", + "docs": ["Trading fee charged for the protocol."], + "type": "u64" + }, + { + "name": "host_fee", + "docs": ["Host fee charged"], + "type": "u64" + } + ] + } + }, + { + "name": "TokenMultiplier", + "docs": [ + "Multiplier for the pool token. Used to normalized token with different decimal into the same precision." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "token_a_multiplier", + "docs": ["Multiplier for token A of the pool."], + "type": "u64" + }, + { + "name": "token_b_multiplier", + "docs": ["Multiplier for token B of the pool."], + "type": "u64" + }, + { + "name": "precision_factor", + "docs": [ + "Record the highest token decimal in the pool. For example, Token A is 6 decimal, token B is 9 decimal. This will save value of 9." + ], + "type": "u8" + } + ] + } + }, + { + "name": "TransferAdmin", + "docs": ["Transfer admin event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "admin", + "docs": ["Old admin of the pool"], + "type": "pubkey" + }, + { + "name": "new_admin", + "docs": ["New admin of the pool"], + "type": "pubkey" + }, + { + "name": "pool", + "docs": ["Pool address"], + "type": "pubkey" + } + ] + } + }, + { + "name": "Vault", + "docs": ["Vault struct"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "enabled", + "docs": [ + "The flag, if admin set enable = false, then the user can only withdraw and cannot deposit in the vault." + ], + "type": "u8" + }, + { + "name": "bumps", + "docs": ["Vault nonce, to create vault seeds"], + "type": { + "defined": { + "name": "VaultBumps" + } + } + }, + { + "name": "total_amount", + "docs": [ + "The total liquidity of the vault, including remaining tokens in token_vault and the liquidity in all strategies." + ], + "type": "u64" + }, + { + "name": "token_vault", + "docs": ["Token account, hold liquidity in vault reserve"], + "type": "pubkey" + }, + { + "name": "fee_vault", + "docs": [ + "Hold lp token of vault, each time rebalance crank is called, vault calculate performance fee and mint corresponding lp token amount to fee_vault. fee_vault is owned by treasury address" + ], + "type": "pubkey" + }, + { + "name": "token_mint", + "docs": ["Token mint that vault supports"], + "type": "pubkey" + }, + { + "name": "lp_mint", + "docs": ["Lp mint of vault"], + "type": "pubkey" + }, + { + "name": "strategies", + "docs": [ + "The list of strategy addresses that vault supports, vault can support up to MAX_STRATEGY strategies at the same time." + ], + "type": { + "array": ["pubkey", 30] + } + }, + { + "name": "base", + "docs": ["The base address to create vault seeds"], + "type": "pubkey" + }, + { + "name": "admin", + "docs": ["Admin of vault"], + "type": "pubkey" + }, + { + "name": "operator", + "docs": [ + "Person who can send the crank. Operator can only send liquidity to strategies that admin defined, and claim reward to account of treasury address" + ], + "type": "pubkey" + }, + { + "name": "locked_profit_tracker", + "docs": ["Stores information for locked profit."], + "type": { + "defined": { + "name": "LockedProfitTracker" + } + } + } + ] + } + }, + { + "name": "VaultBumps", + "docs": ["Vault bumps struct"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "vault_bump", + "docs": ["vault_bump"], + "type": "u8" + }, + { + "name": "token_vault_bump", + "docs": ["token_vault_bump"], + "type": "u8" + } + ] + } + }, + { + "name": "WithdrawProtocolFees", + "docs": ["Withdraw protocol fees"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "docs": ["Pool address"], + "type": "pubkey" + }, + { + "name": "protocol_a_fee", + "docs": ["Protocol A fee"], + "type": "u64" + }, + { + "name": "protocol_b_fee", + "docs": ["Protocol B fee"], + "type": "u64" + }, + { + "name": "protocol_a_fee_owner", + "docs": ["Protocol A fee owner"], + "type": "pubkey" + }, + { + "name": "protocol_b_fee_owner", + "docs": ["Protocol B fee owner"], + "type": "pubkey" + } + ] + } + } + ] +} diff --git a/idls/mercurial_vault.json b/idls/mercurial_vault.json new file mode 100644 index 0000000..9f1ba12 --- /dev/null +++ b/idls/mercurial_vault.json @@ -0,0 +1,1510 @@ +{ + "address": "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi", + "metadata": { + "name": "vault", + "version": "0.9.4", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "docs": ["Program for vault"], + "instructions": [ + { + "name": "add_strategy", + "docs": ["add a strategy"], + "discriminator": [64, 123, 127, 227, 192, 234, 198, 20], + "accounts": [ + { + "name": "vault", + "docs": ["vault"], + "writable": true, + "relations": ["strategy"] + }, + { + "name": "strategy", + "docs": ["strategy"] + }, + { + "name": "admin", + "docs": ["admin"], + "signer": true, + "relations": ["vault"] + } + ], + "args": [] + }, + { + "name": "claim_rewards", + "docs": ["claim rewards from a strategy"], + "discriminator": [4, 144, 132, 71, 116, 23, 151, 80], + "accounts": [ + { + "name": "vault", + "docs": ["vault"] + }, + { + "name": "strategy", + "docs": ["strategy"] + }, + { + "name": "token_program", + "docs": ["token_program"], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_reward_acc", + "docs": ["token_reward_acc"], + "writable": true + }, + { + "name": "operator", + "docs": ["operator"], + "signer": true + } + ], + "args": [] + }, + { + "name": "deposit", + "docs": ["user deposit liquidity to vault"], + "discriminator": [242, 35, 198, 137, 82, 225, 242, 182], + "accounts": [ + { + "name": "vault", + "docs": ["vault"], + "writable": true + }, + { + "name": "token_vault", + "docs": ["token_vault"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "lp_mint", + "docs": ["lp_mint"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "user_token", + "docs": ["user_token"], + "writable": true + }, + { + "name": "user_lp", + "docs": ["user_lp"], + "writable": true + }, + { + "name": "user", + "docs": ["user"], + "signer": true + }, + { + "name": "token_program", + "docs": ["token_program"], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "token_amount", + "type": "u64" + }, + { + "name": "minimum_lp_token_amount", + "type": "u64" + } + ] + }, + { + "name": "deposit_strategy", + "docs": ["deposit liquidity to a strategy"], + "discriminator": [246, 82, 57, 226, 131, 222, 253, 249], + "accounts": [ + { + "name": "vault", + "docs": ["vault"], + "writable": true + }, + { + "name": "strategy", + "docs": ["strategy"], + "writable": true + }, + { + "name": "token_vault", + "docs": ["token_vault"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "fee_vault", + "docs": ["fee_vault"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "lp_mint", + "docs": ["lp_mint"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "strategy_program" + }, + { + "name": "collateral_vault", + "docs": ["collateral_vault"], + "writable": true + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "token_program", + "docs": ["token_program"], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "operator", + "docs": ["operator"], + "signer": true + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "enable_vault", + "docs": ["enable vault"], + "discriminator": [145, 82, 241, 156, 26, 154, 233, 211], + "accounts": [ + { + "name": "vault", + "docs": ["Vault account"], + "writable": true + }, + { + "name": "admin", + "docs": ["Admin account"], + "signer": true, + "relations": ["vault"] + } + ], + "args": [ + { + "name": "enabled", + "type": "u8" + } + ] + }, + { + "name": "get_unlocked_amount", + "docs": ["get unlocked amount"], + "discriminator": [22, 184, 50, 213, 60, 168, 181, 227], + "accounts": [ + { + "name": "vault", + "docs": ["Vault account"] + } + ], + "args": [] + }, + { + "name": "initialize", + "docs": ["initialize new vault"], + "discriminator": [175, 175, 109, 31, 13, 152, 155, 237], + "accounts": [ + { + "name": "vault", + "docs": [ + "This is base account for all vault", + "No need base key now because we only allow 1 vault per token now", + "Vault account" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [118, 97, 117, 108, 116] + }, + { + "kind": "account", + "path": "token_mint" + }, + { + "kind": "const", + "value": [ + 245, 105, 223, 222, 32, 35, 51, 89, 141, 199, 215, 75, 29, + 148, 184, 98, 71, 121, 193, 248, 47, 30, 37, 166, 91, 110, 78, + 248, 163, 190, 155, 155 + ] + } + ] + } + }, + { + "name": "payer", + "docs": ["Payer can be anyone"], + "writable": true, + "signer": true + }, + { + "name": "token_vault", + "docs": ["Token vault account"], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116] + }, + { + "kind": "account", + "path": "vault" + } + ] + } + }, + { + "name": "token_mint", + "docs": ["Token mint account"] + }, + { + "name": "lp_mint", + "docs": ["LP mint account"], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [108, 112, 95, 109, 105, 110, 116] + }, + { + "kind": "account", + "path": "vault" + } + ] + } + }, + { + "name": "rent", + "docs": ["rent"], + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "token_program", + "docs": ["token_program"], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "system_program", + "docs": ["system_program"], + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "initialize_idle_vault", + "docs": ["initialize idle vault the vault that cannot be rebalanced"], + "discriminator": [100, 187, 43, 147, 149, 180, 117, 223], + "accounts": [ + { + "name": "vault", + "docs": ["Vault account"], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [118, 97, 117, 108, 116] + }, + { + "kind": "account", + "path": "token_mint" + }, + { + "kind": "const", + "value": [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ] + } + ] + } + }, + { + "name": "payer", + "docs": ["Payer can be anyone"], + "writable": true, + "signer": true + }, + { + "name": "token_vault", + "docs": ["Token vault account"], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116] + }, + { + "kind": "account", + "path": "vault" + } + ] + } + }, + { + "name": "token_mint", + "docs": ["Token mint account"] + }, + { + "name": "lp_mint", + "docs": ["LP mint"], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [108, 112, 95, 109, 105, 110, 116] + }, + { + "kind": "account", + "path": "vault" + } + ] + } + }, + { + "name": "rent", + "docs": ["rent"], + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "token_program", + "docs": ["token_program"], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "system_program", + "docs": ["system_program"], + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "initialize_strategy", + "docs": [ + "Initialize a strategy and add strategy to vault.strategies index" + ], + "discriminator": [208, 119, 144, 145, 178, 57, 105, 252], + "accounts": [ + { + "name": "vault", + "docs": ["Vault account"], + "writable": true + }, + { + "name": "strategy_program" + }, + { + "name": "strategy", + "docs": ["Strategy account"], + "writable": true + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "collateral_vault", + "docs": ["Collateral vault account"], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, 111, 108, 108, 97, 116, 101, 114, 97, 108, 95, 118, 97, + 117, 108, 116 + ] + }, + { + "kind": "account", + "path": "strategy" + } + ] + } + }, + { + "name": "collateral_mint", + "docs": ["Collateral mint account"] + }, + { + "name": "admin", + "docs": ["Admin account"], + "writable": true, + "signer": true, + "relations": ["vault"] + }, + { + "name": "system_program", + "docs": ["System program account"], + "address": "11111111111111111111111111111111" + }, + { + "name": "rent", + "docs": ["Rent account"], + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "token_program", + "docs": ["Token program account"], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "bumps", + "type": { + "defined": { + "name": "StrategyBumps" + } + } + }, + { + "name": "strategy_type", + "type": { + "defined": { + "name": "StrategyType" + } + } + } + ] + }, + { + "name": "remove_strategy", + "docs": ["remove a strategy"], + "discriminator": [185, 238, 33, 91, 134, 210, 97, 26], + "accounts": [ + { + "name": "vault", + "docs": ["Vault account"], + "writable": true + }, + { + "name": "strategy", + "docs": ["Strategy account"], + "writable": true + }, + { + "name": "strategy_program" + }, + { + "name": "collateral_vault", + "docs": ["Collateral vault account"], + "writable": true + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "token_vault", + "docs": ["token_vault"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "fee_vault", + "docs": ["fee_vault"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "lp_mint", + "docs": ["lp_mint"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "token_program", + "docs": ["token_program"], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "admin", + "docs": ["admin"], + "signer": true, + "relations": ["vault"] + } + ], + "args": [] + }, + { + "name": "remove_strategy2", + "docs": ["remove a strategy by advance payment"], + "discriminator": [138, 104, 208, 148, 126, 35, 195, 14], + "accounts": [ + { + "name": "vault", + "docs": ["Vault account"], + "writable": true + }, + { + "name": "strategy", + "docs": ["Strategy account"], + "writable": true + }, + { + "name": "strategy_program" + }, + { + "name": "collateral_vault", + "docs": ["Collateral vault account"], + "writable": true + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "token_vault", + "docs": ["token_vault"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "token_admin_advance_payment", + "docs": [ + "token_advance_payment", + "the owner of token_advance_payment must be admin" + ], + "writable": true + }, + { + "name": "token_vault_advance_payment", + "docs": [ + "token_vault_advance_payment", + "the account must be different from token_vault and strategy's related token account", + "the owner of token_advance_payment must be vault" + ], + "writable": true + }, + { + "name": "fee_vault", + "docs": ["fee_vault"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "lp_mint", + "docs": ["lp_mint"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "token_program", + "docs": ["token_program"], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "admin", + "docs": ["admin"], + "signer": true, + "relations": ["vault"] + } + ], + "args": [ + { + "name": "max_admin_pay_amount", + "type": "u64" + } + ] + }, + { + "name": "set_operator", + "docs": ["set new operator"], + "discriminator": [238, 153, 101, 169, 243, 131, 36, 1], + "accounts": [ + { + "name": "vault", + "docs": ["Vault account"], + "writable": true + }, + { + "name": "operator" + }, + { + "name": "admin", + "docs": ["admin"], + "signer": true, + "relations": ["vault"] + } + ], + "args": [] + }, + { + "name": "transfer_admin", + "docs": ["transfer admin"], + "discriminator": [42, 242, 66, 106, 228, 10, 111, 156], + "accounts": [ + { + "name": "vault", + "docs": ["Vault account"], + "writable": true + }, + { + "name": "admin", + "docs": ["Admin account"], + "signer": true, + "relations": ["vault"] + }, + { + "name": "new_admin", + "docs": ["New vault admin"], + "signer": true + } + ], + "args": [] + }, + { + "name": "transfer_fee_vault", + "docs": ["transfer fee account"], + "discriminator": [24, 18, 129, 149, 149, 32, 45, 105], + "accounts": [ + { + "name": "vault", + "docs": ["Vault account"], + "writable": true + }, + { + "name": "admin", + "docs": ["Admin account"], + "signer": true, + "relations": ["vault"] + }, + { + "name": "new_fee_vault", + "docs": ["New fee vault account"] + } + ], + "args": [] + }, + { + "name": "update_locked_profit_degradation", + "docs": ["update locked profit degradation"], + "discriminator": [103, 192, 9, 190, 43, 209, 235, 115], + "accounts": [ + { + "name": "vault", + "docs": ["Vault account"], + "writable": true + }, + { + "name": "admin", + "docs": ["Admin account"], + "signer": true, + "relations": ["vault"] + } + ], + "args": [ + { + "name": "locked_profit_degradation", + "type": "u64" + } + ] + }, + { + "name": "withdraw", + "docs": ["user withdraw liquidity from vault"], + "discriminator": [183, 18, 70, 156, 148, 109, 161, 34], + "accounts": [ + { + "name": "vault", + "docs": ["vault"], + "writable": true + }, + { + "name": "token_vault", + "docs": ["token_vault"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "lp_mint", + "docs": ["lp_mint"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "user_token", + "docs": ["user_token"], + "writable": true + }, + { + "name": "user_lp", + "docs": ["user_lp"], + "writable": true + }, + { + "name": "user", + "docs": ["user"], + "signer": true + }, + { + "name": "token_program", + "docs": ["token_program"], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "unmint_amount", + "type": "u64" + }, + { + "name": "min_out_amount", + "type": "u64" + } + ] + }, + { + "name": "withdraw_directly_from_strategy", + "docs": [ + "user withdraw liquidity from vault, if vault reserve doesn't have enough liquidity, it will withdraw from the strategy firstly" + ], + "discriminator": [201, 141, 146, 46, 173, 116, 198, 22], + "accounts": [ + { + "name": "vault", + "docs": ["vault"], + "writable": true + }, + { + "name": "strategy", + "docs": ["strategy"], + "writable": true + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "strategy_program" + }, + { + "name": "collateral_vault", + "docs": ["collateral_vault"], + "writable": true + }, + { + "name": "token_vault", + "docs": ["token_vault"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "lp_mint", + "docs": ["lp_mint"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "fee_vault", + "docs": ["fee_vault"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "user_token", + "docs": ["user_token"], + "writable": true + }, + { + "name": "user_lp", + "docs": ["user_lp"], + "writable": true + }, + { + "name": "user", + "docs": ["user"], + "signer": true + }, + { + "name": "token_program", + "docs": ["token_program"], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "unmint_amount", + "type": "u64" + }, + { + "name": "min_out_amount", + "type": "u64" + } + ] + }, + { + "name": "withdraw_strategy", + "docs": ["withdraw liquidity from a strategy"], + "discriminator": [31, 45, 162, 5, 193, 217, 134, 188], + "accounts": [ + { + "name": "vault", + "docs": ["vault"], + "writable": true + }, + { + "name": "strategy", + "docs": ["strategy"], + "writable": true + }, + { + "name": "token_vault", + "docs": ["token_vault"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "fee_vault", + "docs": ["fee_vault"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "lp_mint", + "docs": ["lp_mint"], + "writable": true, + "relations": ["vault"] + }, + { + "name": "strategy_program" + }, + { + "name": "collateral_vault", + "docs": ["collateral_vault"], + "writable": true + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "token_program", + "docs": ["token_program"], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "operator", + "docs": ["operator"], + "signer": true + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + } + ], + "accounts": [ + { + "name": "Strategy", + "discriminator": [174, 110, 39, 119, 82, 106, 169, 102] + }, + { + "name": "Vault", + "discriminator": [211, 8, 232, 43, 2, 152, 117, 119] + } + ], + "events": [ + { + "name": "AddLiquidity", + "discriminator": [31, 94, 125, 90, 227, 52, 61, 186] + }, + { + "name": "ClaimReward", + "discriminator": [148, 116, 134, 204, 22, 171, 85, 95] + }, + { + "name": "PerformanceFee", + "discriminator": [28, 70, 231, 223, 81, 109, 239, 167] + }, + { + "name": "RemoveLiquidity", + "discriminator": [116, 244, 97, 232, 103, 31, 152, 58] + }, + { + "name": "ReportLoss", + "discriminator": [154, 36, 158, 196, 32, 163, 123, 126] + }, + { + "name": "StrategyDeposit", + "discriminator": [205, 53, 91, 239, 34, 136, 73, 47] + }, + { + "name": "StrategyWithdraw", + "discriminator": [120, 76, 208, 95, 221, 210, 229, 189] + }, + { + "name": "TotalAmount", + "discriminator": [92, 200, 122, 145, 211, 203, 49, 205] + } + ], + "errors": [ + { + "code": 6000, + "name": "VaultIsDisabled", + "msg": "Vault is disabled" + }, + { + "code": 6001, + "name": "ExceededSlippage", + "msg": "Exceeded slippage tolerance" + }, + { + "code": 6002, + "name": "StrategyIsNotExisted", + "msg": "Strategy is not existed" + }, + { + "code": 6003, + "name": "UnAuthorized", + "msg": "UnAuthorized" + }, + { + "code": 6004, + "name": "MathOverflow", + "msg": "Math operation overflow" + }, + { + "code": 6005, + "name": "ProtocolIsNotSupported", + "msg": "Protocol is not supported" + }, + { + "code": 6006, + "name": "UnMatchReserve", + "msg": "Reserve does not support token mint" + }, + { + "code": 6007, + "name": "InvalidLockedProfitDegradation", + "msg": "lockedProfitDegradation is invalid" + }, + { + "code": 6008, + "name": "MaxStrategyReached", + "msg": "Maximum number of strategies have been reached" + }, + { + "code": 6009, + "name": "StrategyExisted", + "msg": "Strategy existed" + }, + { + "code": 6010, + "name": "InvalidUnmintAmount", + "msg": "Invalid unmint amount" + }, + { + "code": 6011, + "name": "InvalidAccountsForStrategy", + "msg": "Invalid accounts for strategy" + }, + { + "code": 6012, + "name": "InvalidBump", + "msg": "Invalid bump" + }, + { + "code": 6013, + "name": "AmountMustGreaterThanZero", + "msg": "Amount must be greater than 0" + }, + { + "code": 6014, + "name": "MangoIsNotSupportedAnymore", + "msg": "Mango is not supported anymore" + }, + { + "code": 6015, + "name": "StrategyIsNotSupported", + "msg": "Strategy is not supported" + }, + { + "code": 6016, + "name": "PayAmountIsExceeded", + "msg": "Pay amount is exceeded" + }, + { + "code": 6017, + "name": "FeeVaultIsNotSet", + "msg": "Fee vault is not set" + }, + { + "code": 6018, + "name": "LendingAssertionViolation", + "msg": "deposit amount in lending is not matched" + }, + { + "code": 6019, + "name": "HaveMoneyInLending", + "msg": "Cannot remove strategy because we have some in lending" + }, + { + "code": 6020, + "name": "InvalidPrecisionLoss", + "msg": "Invalid precision loss" + }, + { + "code": 6021, + "name": "UndeterminedError", + "msg": "Undetermined error" + } + ], + "types": [ + { + "name": "AddLiquidity", + "docs": ["AddLiquidity event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "lp_mint_amount", + "docs": ["lp_mint_amount"], + "type": "u64" + }, + { + "name": "token_amount", + "docs": ["token_amount"], + "type": "u64" + } + ] + } + }, + { + "name": "ClaimReward", + "docs": ["ClaimReward event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "strategy_type", + "docs": ["strategy_type"], + "type": { + "defined": { + "name": "StrategyType" + } + } + }, + { + "name": "token_amount", + "docs": ["token_amount"], + "type": "u64" + }, + { + "name": "mint_account", + "docs": ["mint_account"], + "type": "pubkey" + } + ] + } + }, + { + "name": "LockedProfitTracker", + "docs": ["LockedProfitTracker struct"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "last_updated_locked_profit", + "docs": ["The total locked profit from the last report"], + "type": "u64" + }, + { + "name": "last_report", + "docs": ["The last timestamp (in seconds) rebalancing"], + "type": "u64" + }, + { + "name": "locked_profit_degradation", + "docs": ["Rate per second of degradation"], + "type": "u64" + } + ] + } + }, + { + "name": "PerformanceFee", + "docs": ["PerformanceFee event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "lp_mint_more", + "docs": ["lp_mint_more"], + "type": "u64" + } + ] + } + }, + { + "name": "RemoveLiquidity", + "docs": ["RemoveLiquidity event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "lp_unmint_amount", + "docs": ["lp_unmint_amount"], + "type": "u64" + }, + { + "name": "token_amount", + "docs": ["token_amount"], + "type": "u64" + } + ] + } + }, + { + "name": "ReportLoss", + "docs": ["ReportLoss event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "strategy", + "docs": ["strategy"], + "type": "pubkey" + }, + { + "name": "loss", + "docs": ["loss"], + "type": "u64" + } + ] + } + }, + { + "name": "Strategy", + "docs": ["Strategy struct"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "reserve", + "docs": [ + "Lending pool address, that the strategy will deposit/withdraw balance" + ], + "type": "pubkey" + }, + { + "name": "collateral_vault", + "docs": ["The token account, that holds the collateral token"], + "type": "pubkey" + }, + { + "name": "strategy_type", + "docs": ["Specify type of strategy"], + "type": { + "defined": { + "name": "StrategyType" + } + } + }, + { + "name": "current_liquidity", + "docs": [ + "The liquidity in strategy at the time vault deposit/withdraw from a lending protocol" + ], + "type": "u64" + }, + { + "name": "bumps", + "docs": [ + "Hold some bumps, in case the strategy needs to use other seeds to sign a CPI call." + ], + "type": { + "array": ["u8", 10] + } + }, + { + "name": "vault", + "docs": ["Vault address, that the strategy belongs"], + "type": "pubkey" + }, + { + "name": "is_disable", + "docs": [ + "If we remove strategy by remove_strategy2 endpoint, this account will be never added again" + ], + "type": "u8" + } + ] + } + }, + { + "name": "StrategyBumps", + "docs": ["Strategy bumps struct"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "strategy_index", + "docs": ["strategy_index"], + "type": "u8" + }, + { + "name": "other_bumps", + "docs": ["Bumps of PDAs for the integrated protocol."], + "type": { + "array": ["u8", 10] + } + } + ] + } + }, + { + "name": "StrategyDeposit", + "docs": ["StrategyDeposit event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "strategy_type", + "docs": ["strategy_type"], + "type": { + "defined": { + "name": "StrategyType" + } + } + }, + { + "name": "token_amount", + "docs": ["token_amount"], + "type": "u64" + } + ] + } + }, + { + "name": "StrategyType", + "docs": ["StrategyType struct"], + "type": { + "kind": "enum", + "variants": [ + { + "name": "PortFinanceWithoutLM" + }, + { + "name": "PortFinanceWithLM" + }, + { + "name": "SolendWithoutLM" + }, + { + "name": "Mango" + }, + { + "name": "SolendWithLM" + }, + { + "name": "ApricotWithoutLM" + }, + { + "name": "Francium" + }, + { + "name": "Tulip" + }, + { + "name": "Vault" + }, + { + "name": "Drift" + }, + { + "name": "Frakt" + }, + { + "name": "Marginfi" + }, + { + "name": "Kamino" + }, + { + "name": "JupLend" + } + ] + } + }, + { + "name": "StrategyWithdraw", + "docs": ["StrategyWithdraw event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "strategy_type", + "docs": ["strategy_type"], + "type": { + "defined": { + "name": "StrategyType" + } + } + }, + { + "name": "collateral_amount", + "docs": ["collateral_amount"], + "type": "u64" + }, + { + "name": "estimated_token_amount", + "docs": ["estimated_token_amount"], + "type": "u64" + } + ] + } + }, + { + "name": "TotalAmount", + "docs": ["TotalAmount event"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "total_amount", + "docs": ["total_amount"], + "type": "u64" + } + ] + } + }, + { + "name": "Vault", + "docs": ["Vault struct"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "enabled", + "docs": [ + "The flag, if admin set enable = false, then the user can only withdraw and cannot deposit in the vault." + ], + "type": "u8" + }, + { + "name": "bumps", + "docs": ["Vault nonce, to create vault seeds"], + "type": { + "defined": { + "name": "VaultBumps" + } + } + }, + { + "name": "total_amount", + "docs": [ + "The total liquidity of the vault, including remaining tokens in token_vault and the liquidity in all strategies." + ], + "type": "u64" + }, + { + "name": "token_vault", + "docs": ["Token account, hold liquidity in vault reserve"], + "type": "pubkey" + }, + { + "name": "fee_vault", + "docs": [ + "Hold lp token of vault, each time rebalance crank is called, vault calculate performance fee and mint corresponding lp token amount to fee_vault. fee_vault is owned by treasury address" + ], + "type": "pubkey" + }, + { + "name": "token_mint", + "docs": ["Token mint that vault supports"], + "type": "pubkey" + }, + { + "name": "lp_mint", + "docs": ["Lp mint of vault"], + "type": "pubkey" + }, + { + "name": "strategies", + "docs": [ + "The list of strategy addresses that vault supports, vault can support up to MAX_STRATEGY strategies at the same time." + ], + "type": { + "array": ["pubkey", 30] + } + }, + { + "name": "base", + "docs": ["The base address to create vault seeds"], + "type": "pubkey" + }, + { + "name": "admin", + "docs": ["Admin of vault"], + "type": "pubkey" + }, + { + "name": "operator", + "docs": [ + "Person who can send the crank. Operator can only send liquidity to strategies that admin defined, and claim reward to account of treasury address" + ], + "type": "pubkey" + }, + { + "name": "locked_profit_tracker", + "docs": ["Stores information for locked profit."], + "type": { + "defined": { + "name": "LockedProfitTracker" + } + } + } + ] + } + }, + { + "name": "VaultBumps", + "docs": ["Vault bumps struct"], + "type": { + "kind": "struct", + "fields": [ + { + "name": "vault_bump", + "docs": ["vault_bump"], + "type": "u8" + }, + { + "name": "token_vault_bump", + "docs": ["token_vault_bump"], + "type": "u8" + } + ] + } + } + ] +} diff --git a/programs/zap/Cargo.toml b/programs/zap/Cargo.toml index c38b181..817e039 100644 --- a/programs/zap/Cargo.toml +++ b/programs/zap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zap" -version = "0.2.0" +version = "0.2.1" description = "Created with Anchor" edition = "2021" @@ -25,5 +25,5 @@ bytemuck = { workspace = true, features = ["derive", "min_const_generics"] } dlmm = { path = "../../libs/dlmm" } damm-v2 = { git = "https://github.com/MeteoraAg/damm-v2", features = [ "cpi", -], rev = "d9cef5aaec9cfa1a6d3b0b28d213c87c285127de", package="cp-amm" } -ruint = "1.3.0" \ No newline at end of file +], rev = "d9cef5aaec9cfa1a6d3b0b28d213c87c285127de", package = "cp-amm" } +ruint = "1.3.0" diff --git a/programs/zap/src/constants.rs b/programs/zap/src/constants.rs index 1b33c6e..8a748ab 100644 --- a/programs/zap/src/constants.rs +++ b/programs/zap/src/constants.rs @@ -1,6 +1,12 @@ use anchor_lang::constant; use anchor_lang::{prelude::Pubkey, pubkey}; +#[constant] +pub const DAMM_V1: Pubkey = pubkey!("Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB"); +// https://github.com/MeteoraAg/zap-program/blob/d8a3b5c8115842f95d6df51d7ccce500f5da5127/idls/damm_v1.json#L2865 +#[constant] +pub const DAMM_V1_SWAP_DISC: [u8; 8] = [248, 198, 158, 145, 225, 117, 135, 200]; + #[constant] pub const DAMM_V2: Pubkey = pubkey!("cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"); // https://github.com/MeteoraAg/zap-program/blob/main/idls/damm_v2.json#L3512-L3521 @@ -22,7 +28,8 @@ pub const DLMM: Pubkey = pubkey!("LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo"); pub const DLMM_SWAP2_DISC: [u8; 8] = [65, 75, 63, 76, 235, 91, 91, 136]; #[constant] -pub const WHITELISTED_AMM_PROGRAMS: [(Pubkey, [u8; 8]); 4] = [ +pub const WHITELISTED_AMM_PROGRAMS: [(Pubkey, [u8; 8]); 5] = [ + (DAMM_V1, DAMM_V1_SWAP_DISC), (DAMM_V2, DAMM_V2_SWAP_DISC), (DLMM, DLMM_SWAP2_DISC), (JUP_V6, JUP_V6_ROUTE_DISC), diff --git a/programs/zap/src/instructions/ix_zap_out.rs b/programs/zap/src/instructions/ix_zap_out.rs index e737f35..dab7789 100644 --- a/programs/zap/src/instructions/ix_zap_out.rs +++ b/programs/zap/src/instructions/ix_zap_out.rs @@ -82,9 +82,9 @@ pub fn handle_zap_out<'c: 'info, 'info>( ) -> Result<()> { // validate params params.validate()?; - let disciminator = ¶ms.payload_data[..8]; // first 8 bytes is discriminator + let discriminator = ¶ms.payload_data[..8]; // first 8 bytes is discriminator require!( - is_support_amm_program(ctx.accounts.amm_program.key, disciminator), + is_support_amm_program(ctx.accounts.amm_program.key, discriminator), ZapError::AmmIsNotSupported ); let post_user_token_balance = ctx.accounts.user_token_in_account.amount; diff --git a/tests/common/damm_v1.ts b/tests/common/damm_v1.ts new file mode 100644 index 0000000..31db0b3 --- /dev/null +++ b/tests/common/damm_v1.ts @@ -0,0 +1,792 @@ +import { + ASSOCIATED_TOKEN_PROGRAM_ID, + getAssociatedTokenAddressSync, + TOKEN_PROGRAM_ID, + unpackMint, +} from "@solana/spl-token"; +import { + Keypair, + PublicKey, + SystemProgram, + SYSVAR_RENT_PUBKEY, + ComputeBudgetProgram, + Connection, + clusterApiUrl, + LAMPORTS_PER_SOL, +} from "@solana/web3.js"; +import { + FailedTransactionMetadata, + LiteSVM, + SimulatedTransactionInfo, + TransactionMetadata, +} from "litesvm"; +import { expect } from "chai"; +import type { Amm } from "./idl/damm_v1"; +import DAMMV1IDL from "../../idls/damm_v1.json"; +import { + AnchorProvider, + BN, + Coder, + EventParser, + IdlAccounts, + Program, + Wallet, +} from "@coral-xyz/anchor"; +import { getVaultAccount, PUBLIC_KEY, vaultProgram } from "./vault"; +import { getOrCreateAtA, sendTransaction } from "./utils"; + +export function createDammV1Program() { + const wallet = new Wallet(Keypair.generate()); + const provider = new AnchorProvider( + new Connection(clusterApiUrl("devnet")), + wallet, + {} + ); + const program = new Program(DAMMV1IDL as Amm, provider); + return program; +} + +export const dammV1Program = createDammV1Program(); + +export const DAMM_V1_PROGRAM_ID = new PublicKey(DAMMV1IDL.address); + +export const DAMM_V1_SWAP_DISC = [248, 198, 158, 145, 225, 117, 135, 200]; + +const FEE_OWNER = new PublicKey("6WaLrrRfReGKBYUSkmx2K6AuT21ida4j8at2SUiZdXu8"); + +export const getRemoveLiquidityOutAmount = async ( + svm: LiteSVM, + params: { + pool: PublicKey; + withdrawAmount: BN; + userKeypair: Keypair; + } +): Promise<{ + aOutAmount: BN; + bOutAmount: BN; +}> => { + const { pool, withdrawAmount, userKeypair } = params; + const poolAccount = getDammV1Pool(svm, pool); + + const aVault = getVaultAccount(svm, poolAccount.aVault); + const bVault = getVaultAccount(svm, poolAccount.bVault); + + const [userPoolLp, userTokenA, userTokenB] = await Promise.all([ + getOrCreateAtA( + svm, + userKeypair, + poolAccount.lpMint, + userKeypair.publicKey, + TOKEN_PROGRAM_ID + ), + getOrCreateAtA( + svm, + userKeypair, + poolAccount.tokenAMint, + userKeypair.publicKey, + TOKEN_PROGRAM_ID + ), + getOrCreateAtA( + svm, + userKeypair, + poolAccount.tokenBMint, + userKeypair.publicKey, + TOKEN_PROGRAM_ID + ), + ]); + + const transaction = await dammV1Program.methods + .removeBalanceLiquidity(withdrawAmount, new BN(0), new BN(0)) + .accountsPartial({ + aTokenVault: aVault.tokenVault, + bTokenVault: bVault.tokenVault, + aVault: poolAccount.aVault, + bVault: poolAccount.bVault, + pool, + user: userKeypair.publicKey, + userAToken: userTokenA, + userBToken: userTokenB, + aVaultLp: poolAccount.aVaultLp, + bVaultLp: poolAccount.bVaultLp, + aVaultLpMint: aVault.lpMint, + bVaultLpMint: bVault.lpMint, + lpMint: poolAccount.lpMint, + tokenProgram: TOKEN_PROGRAM_ID, + vaultProgram: vaultProgram.programId, + userPoolLp: userPoolLp, + }) + .transaction(); + + transaction.feePayer = userKeypair.publicKey; + transaction.recentBlockhash = svm.latestBlockhash(); + transaction.sign(userKeypair); + const simulation = svm.simulateTransaction(transaction); + + expect(simulation).instanceOf(SimulatedTransactionInfo); + + const events = parseAnchorEvents( + simulation.meta().logs(), + dammV1Program.programId, + dammV1Program.coder + ); + + const { tokenAOutAmount, tokenBOutAmount } = events.find( + (e) => e.name === "removeLiquidity" + ).data; + + return { + aOutAmount: tokenAOutAmount, + bOutAmount: tokenBOutAmount, + }; +}; + +export const getProtocolFeeTokenPDA = ( + tokenA: PublicKey, + tokenB: PublicKey, + poolPubkey: PublicKey, + ammProgram: Program +) => { + const feeTokenA = PublicKey.findProgramAddressSync( + [Buffer.from("fee"), tokenA.toBuffer(), poolPubkey.toBuffer()], + ammProgram.programId + )[0]; + + const feeTokenB = PublicKey.findProgramAddressSync( + [Buffer.from("fee"), tokenB.toBuffer(), poolPubkey.toBuffer()], + ammProgram.programId + )[0]; + + return [feeTokenA, feeTokenB]; +}; + +export const getPoolPdas = ( + poolPubkey: PublicKey, + aVault: PublicKey, + bVault: PublicKey, + ammProgram: Program +) => { + const aVaultLpPda = PublicKey.findProgramAddressSync( + [aVault.toBuffer(), poolPubkey.toBuffer()], + ammProgram.programId + ); + const bVaultLpPda = PublicKey.findProgramAddressSync( + [bVault.toBuffer(), poolPubkey.toBuffer()], + ammProgram.programId + ); + + return { + aVaultLpPda, + bVaultLpPda, + }; +}; + +export const METAPLEX_PROGRAM = new PublicKey( + "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" +); + +export const deriveMetadataPda = (mint: PublicKey) => { + return PublicKey.findProgramAddressSync( + [Buffer.from("metadata"), METAPLEX_PROGRAM.toBuffer(), mint.toBuffer()], + METAPLEX_PROGRAM + ); +}; + +export interface ConstantProduct { + constantProduct: {}; +} +export interface Stable { + stable: { + amp: BN; + tokenMultiplier: TokenMultiplier; + depeg: Depeg; + lastAmpUpdatedTimestamp: BN; + }; +} + +export interface DepegNone { + none: {}; +} + +export interface DepegMarinade { + marinade: {}; +} + +export interface DepegLido { + lido: {}; +} + +export interface TokenMultiplier { + tokenAMultiplier: BN; + tokenBMultiplier: BN; + precisionFactor: number; +} + +export interface Depeg { + baseVirtualPrice: BN; + baseCacheUpdated: BN; + depegType: DepegNone | DepegLido | DepegMarinade; +} + +export const DepegType = { + none: (): DepegNone => { + return { + none: {}, + }; + }, + marinade: (): DepegMarinade => { + return { + marinade: {}, + }; + }, + lido: (): DepegLido => { + return { + lido: {}, + }; + }, +}; + +export const CurveType = { + stable: ( + amp: BN, + tokenMultiplier: TokenMultiplier, + depeg: Depeg, + lastAmpUpdatedTimestamp: BN + ): Stable => { + return { + stable: { + amp, + tokenMultiplier, + depeg, + lastAmpUpdatedTimestamp, + }, + }; + }, + + constantProduct: (): ConstantProduct => { + return { + constantProduct: {}, + }; + }, +}; + +export function encodeCurveType(curve: Stable | ConstantProduct) { + if (curve["constantProduct"]) { + return 0; + } else if (curve["stable"]) { + return 1; + } else { + throw new Error("Unknown curve type"); + } +} + +export function getDammV1Pool(svm: LiteSVM, pool: PublicKey) { + const poolAccountBytes = svm.getAccount(pool); + if (poolAccountBytes) + return dammV1Program.coder.accounts.decode( + "pool", + Buffer.from(poolAccountBytes.data) + ) as IdlAccounts["pool"]; +} + +export function parseAnchorEvents( + logs: string[], + programId: PublicKey, + coder: Coder +) { + const eventParser = new EventParser(programId, coder); + const events: any[] = []; + + try { + const parsedEvents = eventParser.parseLogs(logs); + events.push(...parsedEvents); + } catch (e) { + // Event parsing may fail if no events in logs + console.warn("Failed to parse events:", e); + } + + return events; +} + +export const getPoolInfo = async (svm: LiteSVM, pool: PublicKey) => { + const poolAccount = getDammV1Pool(svm, pool); + const aVault = getVaultAccount(svm, poolAccount.aVault); + const bVault = getVaultAccount(svm, poolAccount.bVault); + + const transaction = await dammV1Program.methods + .getPoolInfo() + .accountsPartial({ + aVault: poolAccount.aVault, + aVaultLp: poolAccount.aVaultLp, + aVaultLpMint: aVault.lpMint, + bVault: poolAccount.bVault, + bVaultLp: poolAccount.bVaultLp, + bVaultLpMint: bVault.lpMint, + lpMint: poolAccount.lpMint, + pool, + }) + .transaction(); + + const payer = Keypair.generate(); + svm.airdrop(payer.publicKey, BigInt(LAMPORTS_PER_SOL)); + transaction.feePayer = payer.publicKey; + transaction.recentBlockhash = svm.latestBlockhash(); + transaction.sign(payer); + const simulation = svm.simulateTransaction(transaction); + + expect(simulation).instanceOf(SimulatedTransactionInfo); + + const events = parseAnchorEvents( + simulation.meta().logs(), + dammV1Program.programId, + dammV1Program.coder + ); + + const { tokenAAmount, tokenBAmount, virtualPrice } = events.find( + (e) => e.name === "poolInfo" + ).data; + + return { + virtualPrice, + tokenAAmount, + tokenBAmount, + } as { + tokenAAmount: BN; + tokenBAmount: BN; + virtualPrice: number; + }; +}; + +export const getShareByAmount = ( + depositAmount: BN, + lpTotalSupply: BN, + totalTokenAmount: BN +) => { + return depositAmount.mul(lpTotalSupply).div(totalTokenAmount); +}; + +export const getQuote = (amountA: BN, reserveA: BN, reserveB: BN) => { + return reserveB.mul(amountA).div(reserveA); +}; + +export const getAddLiquidityInputAmount = async ( + svm: LiteSVM, + getAddLiquidityInputAmountParams: { + pool: PublicKey; + depositAmount: BN; + depositTokenMint: PublicKey; + } +): Promise<{ + lpAmount: BN; + aDepositAmount: BN; + bDepositAmount: BN; +}> => { + const { depositAmount, depositTokenMint, pool } = + getAddLiquidityInputAmountParams; + + const poolAccount = await getDammV1Pool(svm, pool); + + const lpMintAccount = svm.getAccount(poolAccount.lpMint); + const lpMintAccountWithBuffer = { + ...lpMintAccount, + data: Buffer.from(lpMintAccount.data), + }; + const lpMint = unpackMint(poolAccount.lpMint, lpMintAccountWithBuffer); + const poolLpSupply = lpMint.supply; + + const { tokenAAmount, tokenBAmount } = await getPoolInfo(svm, pool); + + let lpAmount: BN; + let aDepositAmount: BN; + let bDepositAmount: BN; + + if (depositTokenMint.equals(poolAccount.tokenAMint)) { + lpAmount = getShareByAmount( + depositAmount, + new BN(poolLpSupply), + tokenAAmount + ); + aDepositAmount = depositAmount; + bDepositAmount = getQuote(aDepositAmount, tokenAAmount, tokenBAmount); + } else { + lpAmount = getShareByAmount( + depositAmount, + new BN(poolLpSupply), + tokenBAmount + ); + bDepositAmount = depositAmount; + aDepositAmount = getQuote(bDepositAmount, tokenBAmount, tokenAAmount); + } + + return { + lpAmount, + aDepositAmount, + bDepositAmount, + }; +}; + +export const addBalanceLiquidity = async ( + svm: LiteSVM, + addLiquidityParams: { + pool: PublicKey; + lpAmount: BN; + maxATokenAmount: BN; + maxBTokenAmount: BN; + userKeypair: Keypair; + } +) => { + const { pool, lpAmount, maxATokenAmount, maxBTokenAmount, userKeypair } = + addLiquidityParams; + + const poolAccount = getDammV1Pool(svm, pool); + + const [userPoolLp, userTokenA, userTokenB] = await Promise.all([ + getOrCreateAtA( + svm, + userKeypair, + poolAccount.lpMint, + userKeypair.publicKey, + TOKEN_PROGRAM_ID + ), + getOrCreateAtA( + svm, + userKeypair, + poolAccount.tokenAMint, + userKeypair.publicKey, + TOKEN_PROGRAM_ID + ), + getOrCreateAtA( + svm, + userKeypair, + poolAccount.tokenBMint, + userKeypair.publicKey, + TOKEN_PROGRAM_ID + ), + ]); + + const aVault = getVaultAccount(svm, poolAccount.aVault); + const bVault = getVaultAccount(svm, poolAccount.bVault); + + const transaction = await dammV1Program.methods + .addBalanceLiquidity(lpAmount, maxATokenAmount, maxBTokenAmount) + .accountsPartial({ + aTokenVault: aVault.tokenVault, + bTokenVault: bVault.tokenVault, + aVault: poolAccount.aVault, + bVault: poolAccount.bVault, + pool, + user: userKeypair.publicKey, + userAToken: userTokenA, + userBToken: userTokenB, + aVaultLp: poolAccount.aVaultLp, + bVaultLp: poolAccount.bVaultLp, + aVaultLpMint: aVault.lpMint, + bVaultLpMint: bVault.lpMint, + lpMint: poolAccount.lpMint, + tokenProgram: TOKEN_PROGRAM_ID, + vaultProgram: vaultProgram.programId, + userPoolLp, + }) + .transaction(); + + sendTransaction(svm, transaction, [userKeypair]); +}; + +export const removeLiquidity = async ( + svm: LiteSVM, + removeLiquidityParams: { + pool: PublicKey; + withdrawAmount: BN; + minAOutAmount: BN; + minBOutAmount: BN; + userKeypair: Keypair; + } +) => { + const { minAOutAmount, minBOutAmount, pool, userKeypair, withdrawAmount } = + removeLiquidityParams; + + const poolAccount = getDammV1Pool(svm, pool); + + const aVault = getVaultAccount(svm, poolAccount.aVault); + const bVault = getVaultAccount(svm, poolAccount.bVault); + + const [userPoolLp, userTokenA, userTokenB] = await Promise.all([ + getOrCreateAtA( + svm, + userKeypair, + poolAccount.lpMint, + userKeypair.publicKey, + TOKEN_PROGRAM_ID + ), + getOrCreateAtA( + svm, + userKeypair, + poolAccount.tokenAMint, + userKeypair.publicKey, + TOKEN_PROGRAM_ID + ), + getOrCreateAtA( + svm, + userKeypair, + poolAccount.tokenBMint, + userKeypair.publicKey, + TOKEN_PROGRAM_ID + ), + ]); + + return await dammV1Program.methods + .removeBalanceLiquidity(withdrawAmount, minAOutAmount, minBOutAmount) + .accountsPartial({ + aTokenVault: aVault.tokenVault, + bTokenVault: bVault.tokenVault, + aVault: poolAccount.aVault, + bVault: poolAccount.bVault, + pool, + user: userKeypair.publicKey, + userAToken: userTokenA, + userBToken: userTokenB, + aVaultLp: poolAccount.aVaultLp, + bVaultLp: poolAccount.bVaultLp, + aVaultLpMint: aVault.lpMint, + bVaultLpMint: bVault.lpMint, + lpMint: poolAccount.lpMint, + tokenProgram: TOKEN_PROGRAM_ID, + vaultProgram: vaultProgram.programId, + userPoolLp: userPoolLp, + }) + .transaction(); +}; + +export function getDammV1RemainingAccounts( + svm: LiteSVM, + pool: PublicKey, + user: PublicKey, + userInputTokenAccount: PublicKey, + userTokenOutAccount: PublicKey, + protocolTokenFee: PublicKey +) { + const poolState = getDammV1Pool(svm, pool); + const aVault = getVaultAccount(svm, poolState.aVault); + const bVault = getVaultAccount(svm, poolState.bVault); + const remainingAccounts: { + isSigner: boolean; + isWritable: boolean; + pubkey: PublicKey; + }[] = [ + { + isSigner: false, + isWritable: true, + pubkey: pool, + }, + { + isSigner: false, + isWritable: true, + pubkey: userInputTokenAccount, + }, + { + isSigner: false, + isWritable: true, + pubkey: userTokenOutAccount, + }, + { + isSigner: false, + isWritable: true, + pubkey: poolState.aVault, + }, + { + isSigner: false, + isWritable: true, + pubkey: poolState.bVault, + }, + { + isSigner: false, + isWritable: true, + pubkey: aVault.tokenVault, + }, + { + isSigner: false, + isWritable: true, + pubkey: bVault.tokenVault, + }, + { + isSigner: false, + isWritable: true, + pubkey: aVault.lpMint, + }, + { + isSigner: false, + isWritable: true, + pubkey: bVault.lpMint, + }, + { + isSigner: false, + isWritable: true, + pubkey: poolState.aVaultLp, + }, + { + isSigner: false, + isWritable: true, + pubkey: poolState.bVaultLp, + }, + { + isSigner: false, + isWritable: true, + pubkey: protocolTokenFee, + }, + { + isSigner: true, + isWritable: false, + pubkey: user, + }, + { + isSigner: false, + isWritable: false, + pubkey: vaultProgram.programId, + }, + { + isSigner: false, + isWritable: false, + pubkey: TOKEN_PROGRAM_ID, + }, + ]; + + return remainingAccounts; +} + +export const initializePermissionedPool = async ( + svm, + param: { + aVault: PublicKey; + bVault: PublicKey; + aDepositAmount: BN; + bDepositAmount: BN; + curve: ConstantProduct | Stable; + adminKeypair: Keypair; + poolKeypair: Keypair; + adminLpMint?: PublicKey; + } +): Promise => { + const { + aVault, + bVault, + adminKeypair, + curve, + aDepositAmount, + bDepositAmount, + poolKeypair, + } = param; + + const [poolLpMint, _poolLpMintBump] = PublicKey.findProgramAddressSync( + [Buffer.from("lp_mint"), poolKeypair.publicKey.toBuffer()], + dammV1Program.programId + ); + + const [mintMetadata, _mintMetadataBump] = deriveMetadataPda(poolLpMint); + + const aVaultAccount = getVaultAccount(svm, aVault); + const bVaultAccount = getVaultAccount(svm, bVault); + + const { aVaultLpPda, bVaultLpPda } = getPoolPdas( + poolKeypair.publicKey, + aVault, + bVault, + dammV1Program + ); + + const adminPoolLp = getAssociatedTokenAddressSync( + poolLpMint, + adminKeypair.publicKey + ); + + const [adminTokenA, adminTokenB] = await Promise.all([ + getOrCreateAtA( + svm, + adminKeypair, + aVaultAccount.tokenMint, + adminKeypair.publicKey, + TOKEN_PROGRAM_ID + ), + getOrCreateAtA( + svm, + adminKeypair, + bVaultAccount.tokenMint, + adminKeypair.publicKey, + TOKEN_PROGRAM_ID + ), + ]); + + const [protocolTokenAFee, protocolTokenBFee] = getProtocolFeeTokenPDA( + aVaultAccount.tokenMint, + bVaultAccount.tokenMint, + poolKeypair.publicKey, + dammV1Program + ); + + const setComputeUnitLimitIx = ComputeBudgetProgram.setComputeUnitLimit({ + units: 1_400_000, + }); + + const bootstrapLiquidityIx = await dammV1Program.methods + .bootstrapLiquidity(aDepositAmount, bDepositAmount) + .accountsPartial({ + pool: poolKeypair.publicKey, + aVault, + bVault, + aVaultLpMint: aVaultAccount.lpMint, + bVaultLpMint: bVaultAccount.lpMint, + aVaultLp: aVaultLpPda[PUBLIC_KEY], + bVaultLp: bVaultLpPda[PUBLIC_KEY], + lpMint: poolLpMint, + userPoolLp: adminPoolLp, + user: adminKeypair.publicKey, + userAToken: adminTokenA, + userBToken: adminTokenB, + aTokenVault: aVaultAccount.tokenVault, + bTokenVault: bVaultAccount.tokenVault, + vaultProgram: vaultProgram.programId, + tokenProgram: TOKEN_PROGRAM_ID, + }) + .instruction(); + + const transaction = await dammV1Program.methods + .initializePermissionedPool(curve as any) + .accountsPartial({ + pool: poolKeypair.publicKey, + tokenAMint: aVaultAccount.tokenMint, + tokenBMint: bVaultAccount.tokenMint, + aVault, + bVault, + aVaultLpMint: aVaultAccount.lpMint, + bVaultLpMint: bVaultAccount.lpMint, + aVaultLp: aVaultLpPda[PUBLIC_KEY], + bVaultLp: bVaultLpPda[PUBLIC_KEY], + lpMint: poolLpMint, + adminTokenA, + adminTokenB, + protocolTokenAFee, + protocolTokenBFee, + adminPoolLp, + admin: adminKeypair.publicKey, + feeOwner: FEE_OWNER, + rent: SYSVAR_RENT_PUBKEY, + metadataProgram: METAPLEX_PROGRAM, + mintMetadata, + vaultProgram: vaultProgram.programId, + tokenProgram: TOKEN_PROGRAM_ID, + systemProgram: SystemProgram.programId, + associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, + }) + .preInstructions([setComputeUnitLimitIx]) + .postInstructions([bootstrapLiquidityIx]) + .transaction(); + + transaction.recentBlockhash = svm.latestBlockhash(); + transaction.sign(adminKeypair, poolKeypair); + const result = svm.sendTransaction(transaction); + if (result instanceof FailedTransactionMetadata) { + console.log(result.toString()); + // console.log(result.meta().logs()); + } + expect(result).instanceOf(TransactionMetadata); + + return poolKeypair.publicKey; +}; diff --git a/tests/common/endpoints/zapOut.ts b/tests/common/endpoints/zapOut.ts index bc351cc..a3ac2c6 100644 --- a/tests/common/endpoints/zapOut.ts +++ b/tests/common/endpoints/zapOut.ts @@ -37,6 +37,12 @@ import { getTokenProgram, } from "../utils"; import { getDammV2Pool } from "../pda"; +import { + DAMM_V1_PROGRAM_ID, + DAMM_V1_SWAP_DISC, + getDammV1Pool, + getDammV1RemainingAccounts, +} from "../damm_v1"; export const ZAP_PROGRAM_ID = new PublicKey(ZapIDL.address); @@ -53,7 +59,72 @@ export function createZapProgram(): ZapProgram { return program; } -export async function zapOutDammv2( +export async function zapOutDammV1( + svm: LiteSVM, + user: PublicKey, + inputTokenMint: PublicKey, + pool: PublicKey +): Promise { + const zapProgram = createZapProgram(); + + const poolState = getDammV1Pool(svm, pool); + const isTokenA = poolState.tokenAMint.equals(inputTokenMint); + const outputTokenMint = isTokenA + ? poolState.tokenBMint + : poolState.tokenAMint; + const protocolTokenFee = isTokenA + ? poolState.protocolTokenAFee + : poolState.protocolTokenBFee; + const inputTokenProgram = getTokenProgram(svm, inputTokenMint); + const outputTokenProgram = getTokenProgram(svm, outputTokenMint); + + const userTokenInAccount = getAssociatedTokenAddressSync( + inputTokenMint, + user, + true, + inputTokenProgram + ); + const userTokenOutAccount = getAssociatedTokenAddressSync( + outputTokenMint, + user, + true, + outputTokenProgram + ); + + const preUserTokenBalance = getTokenBalance(svm, userTokenInAccount); + + const remainingAccounts = getDammV1RemainingAccounts( + svm, + pool, + user, + userTokenInAccount, + userTokenOutAccount, + protocolTokenFee + ); + const minAmountOutBuffer = new BN(10).toArrayLike(Buffer, "le", 8); + const amount = new BN(0).toArrayLike(Buffer, "le", 8); + const payloadData = Buffer.concat([ + Buffer.from(DAMM_V1_SWAP_DISC), + amount, + minAmountOutBuffer, + ]); + return await zapProgram.methods + .zapOut({ + percentage: 100, + offsetAmountIn: 8, + preUserTokenBalance, + maxSwapAmount: new BN("100000000000"), + payloadData, + }) + .accountsPartial({ + userTokenInAccount, + ammProgram: DAMM_V1_PROGRAM_ID, + }) + .remainingAccounts(remainingAccounts) + .transaction(); +} + +export async function zapOutDammV2( svm: LiteSVM, user: PublicKey, inputTokenMint: PublicKey, diff --git a/tests/common/idl/damm_v1.ts b/tests/common/idl/damm_v1.ts new file mode 100644 index 0000000..9145d2e --- /dev/null +++ b/tests/common/idl/damm_v1.ts @@ -0,0 +1,5365 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/amm.json`. + */ +export type Amm = { + address: "SNPmGgnywBvvrAKMLundzG6StojyHTHDLu7T4sdhP4k"; + metadata: { + name: "amm"; + version: "0.5.3"; + spec: "0.1.0"; + description: "Mercurial Dynamic AMM"; + }; + docs: ["Program for AMM"]; + instructions: [ + { + name: "addBalanceLiquidity"; + docs: ["Deposit tokens to the pool in a balanced ratio."]; + discriminator: [168, 227, 50, 62, 189, 171, 84, 176]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA)"]; + writable: true; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + writable: true; + relations: ["pool"]; + }, + { + name: "userPoolLp"; + docs: [ + "user pool lp token account. lp will be burned from this account upon success liquidity removal." + ]; + writable: true; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "aVault"; + docs: [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "bVault"; + docs: [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "aVaultLpMint"; + docs: ["LP token mint of vault a"]; + writable: true; + }, + { + name: "bVaultLpMint"; + docs: ["LP token mint of vault b"]; + writable: true; + }, + { + name: "aTokenVault"; + docs: ["Token vault account of vault A"]; + writable: true; + }, + { + name: "bTokenVault"; + docs: ["Token vault account of vault B"]; + writable: true; + }, + { + name: "userAToken"; + docs: [ + "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ]; + writable: true; + }, + { + name: "userBToken"; + docs: [ + "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ]; + writable: true; + }, + { + name: "user"; + docs: [ + "User account. Must be owner of user_a_token, and user_b_token." + ]; + signer: true; + }, + { + name: "vaultProgram"; + docs: [ + "Vault program. the pool will deposit/withdraw liquidity from the vault." + ]; + address: "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"; + }, + { + name: "tokenProgram"; + docs: ["Token program."]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + } + ]; + args: [ + { + name: "poolTokenAmount"; + type: "u64"; + }, + { + name: "maximumTokenAAmount"; + type: "u64"; + }, + { + name: "maximumTokenBAmount"; + type: "u64"; + } + ]; + }, + { + name: "addImbalanceLiquidity"; + docs: [ + "Deposit tokens to the pool in an imbalance ratio. Only supported by pool with stable swap curve." + ]; + discriminator: [79, 35, 122, 84, 173, 15, 93, 191]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA)"]; + writable: true; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + writable: true; + relations: ["pool"]; + }, + { + name: "userPoolLp"; + docs: [ + "user pool lp token account. lp will be burned from this account upon success liquidity removal." + ]; + writable: true; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "aVault"; + docs: [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "bVault"; + docs: [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "aVaultLpMint"; + docs: ["LP token mint of vault a"]; + writable: true; + }, + { + name: "bVaultLpMint"; + docs: ["LP token mint of vault b"]; + writable: true; + }, + { + name: "aTokenVault"; + docs: ["Token vault account of vault A"]; + writable: true; + }, + { + name: "bTokenVault"; + docs: ["Token vault account of vault B"]; + writable: true; + }, + { + name: "userAToken"; + docs: [ + "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ]; + writable: true; + }, + { + name: "userBToken"; + docs: [ + "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ]; + writable: true; + }, + { + name: "user"; + docs: [ + "User account. Must be owner of user_a_token, and user_b_token." + ]; + signer: true; + }, + { + name: "vaultProgram"; + docs: [ + "Vault program. the pool will deposit/withdraw liquidity from the vault." + ]; + address: "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"; + }, + { + name: "tokenProgram"; + docs: ["Token program."]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + } + ]; + args: [ + { + name: "minimumPoolTokenAmount"; + type: "u64"; + }, + { + name: "tokenAAmount"; + type: "u64"; + }, + { + name: "tokenBAmount"; + type: "u64"; + } + ]; + }, + { + name: "bootstrapLiquidity"; + docs: ["Bootstrap the pool when liquidity is depleted."]; + discriminator: [4, 228, 215, 71, 225, 253, 119, 206]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA)"]; + writable: true; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + writable: true; + relations: ["pool"]; + }, + { + name: "userPoolLp"; + docs: [ + "user pool lp token account. lp will be burned from this account upon success liquidity removal." + ]; + writable: true; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "aVault"; + docs: [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "bVault"; + docs: [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "aVaultLpMint"; + docs: ["LP token mint of vault a"]; + writable: true; + }, + { + name: "bVaultLpMint"; + docs: ["LP token mint of vault b"]; + writable: true; + }, + { + name: "aTokenVault"; + docs: ["Token vault account of vault A"]; + writable: true; + }, + { + name: "bTokenVault"; + docs: ["Token vault account of vault B"]; + writable: true; + }, + { + name: "userAToken"; + docs: [ + "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ]; + writable: true; + }, + { + name: "userBToken"; + docs: [ + "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ]; + writable: true; + }, + { + name: "user"; + docs: [ + "User account. Must be owner of user_a_token, and user_b_token." + ]; + signer: true; + }, + { + name: "vaultProgram"; + docs: [ + "Vault program. the pool will deposit/withdraw liquidity from the vault." + ]; + address: "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"; + }, + { + name: "tokenProgram"; + docs: ["Token program."]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + } + ]; + args: [ + { + name: "tokenAAmount"; + type: "u64"; + }, + { + name: "tokenBAmount"; + type: "u64"; + } + ]; + }, + { + name: "claimFee"; + docs: ["Claim fee"]; + discriminator: [169, 32, 79, 137, 136, 232, 70, 137]; + accounts: [ + { + name: "pool"; + docs: ["Pool account"]; + writable: true; + relations: ["lockEscrow"]; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + writable: true; + relations: ["pool"]; + }, + { + name: "lockEscrow"; + docs: ["Lock account"]; + writable: true; + }, + { + name: "owner"; + docs: ["Owner of lock account"]; + writable: true; + signer: true; + relations: ["lockEscrow"]; + }, + { + name: "sourceTokens"; + docs: ["owner lp token account"]; + writable: true; + }, + { + name: "escrowVault"; + docs: ["Escrow vault"]; + writable: true; + relations: ["lockEscrow"]; + }, + { + name: "tokenProgram"; + docs: ["Token program."]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "aTokenVault"; + docs: ["Token vault account of vault A"]; + writable: true; + }, + { + name: "bTokenVault"; + docs: ["Token vault account of vault B"]; + writable: true; + }, + { + name: "aVault"; + docs: [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "bVault"; + docs: [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "aVaultLpMint"; + docs: ["LP token mint of vault a"]; + writable: true; + }, + { + name: "bVaultLpMint"; + docs: ["LP token mint of vault b"]; + writable: true; + }, + { + name: "userAToken"; + docs: [ + "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ]; + writable: true; + }, + { + name: "userBToken"; + docs: [ + "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ]; + writable: true; + }, + { + name: "vaultProgram"; + docs: [ + "Vault program. the pool will deposit/withdraw liquidity from the vault." + ]; + address: "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"; + } + ]; + args: [ + { + name: "maxAmount"; + type: "u64"; + } + ]; + }, + { + name: "closeConfig"; + docs: ["Close config"]; + discriminator: [145, 9, 72, 157, 95, 125, 61, 85]; + accounts: [ + { + name: "config"; + writable: true; + }, + { + name: "admin"; + writable: true; + signer: true; + }, + { + name: "rentReceiver"; + writable: true; + } + ]; + args: []; + }, + { + name: "closeOperatorAccount"; + discriminator: [171, 9, 213, 74, 120, 23, 3, 29]; + accounts: [ + { + name: "operator"; + writable: true; + }, + { + name: "signer"; + signer: true; + }, + { + name: "rentReceiver"; + writable: true; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: []; + }, + { + name: "createConfig"; + docs: ["Create config"]; + discriminator: [201, 207, 243, 114, 75, 111, 47, 189]; + accounts: [ + { + name: "config"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [99, 111, 110, 102, 105, 103]; + }, + { + kind: "arg"; + path: "config_parameters.index"; + } + ]; + }; + }, + { + name: "admin"; + writable: true; + signer: true; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + } + ]; + args: [ + { + name: "configParameters"; + type: { + defined: { + name: "configParameters"; + }; + }; + } + ]; + }, + { + name: "createLockEscrow"; + docs: ["Create lock account"]; + discriminator: [54, 87, 165, 19, 69, 227, 218, 224]; + accounts: [ + { + name: "pool"; + docs: ["Pool account"]; + }, + { + name: "lockEscrow"; + docs: ["Lock account"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [108, 111, 99, 107, 95, 101, 115, 99, 114, 111, 119]; + }, + { + kind: "account"; + path: "pool"; + }, + { + kind: "account"; + path: "owner"; + } + ]; + }; + }, + { + name: "owner"; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + relations: ["pool"]; + }, + { + name: "payer"; + docs: ["Payer account"]; + writable: true; + signer: true; + }, + { + name: "systemProgram"; + docs: ["System program."]; + address: "11111111111111111111111111111111"; + } + ]; + args: []; + }, + { + name: "createMintMetadata"; + docs: ["Create mint metadata account for old pools"]; + discriminator: [13, 70, 168, 41, 250, 100, 148, 90]; + accounts: [ + { + name: "pool"; + docs: ["Pool account"]; + }, + { + name: "lpMint"; + docs: ["LP mint account of the pool"]; + relations: ["pool"]; + }, + { + name: "aVaultLp"; + docs: ["Vault A LP account of the pool"]; + relations: ["pool"]; + }, + { + name: "mintMetadata"; + writable: true; + }, + { + name: "metadataProgram"; + address: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"; + }, + { + name: "systemProgram"; + docs: ["System program."]; + address: "11111111111111111111111111111111"; + }, + { + name: "payer"; + docs: ["Payer"]; + writable: true; + signer: true; + } + ]; + args: []; + }, + { + name: "createOperatorAccount"; + discriminator: [221, 64, 246, 149, 240, 153, 229, 163]; + accounts: [ + { + name: "operator"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [111, 112, 101, 114, 97, 116, 111, 114]; + }, + { + kind: "account"; + path: "whitelistedAddress"; + } + ]; + }; + }, + { + name: "whitelistedAddress"; + }, + { + name: "signer"; + signer: true; + }, + { + name: "payer"; + writable: true; + signer: true; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: [ + { + name: "permission"; + type: "u128"; + } + ]; + }, + { + name: "enableOrDisablePool"; + docs: [ + "Enable or disable a pool. A disabled pool allow only remove balanced liquidity operation." + ]; + discriminator: [128, 6, 228, 131, 55, 161, 52, 169]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA)"]; + writable: true; + }, + { + name: "admin"; + docs: ["Admin account. Must be owner of the pool."]; + signer: true; + } + ]; + args: [ + { + name: "enable"; + type: "bool"; + } + ]; + }, + { + name: "getPoolInfo"; + docs: ["Get the general information of the pool."]; + discriminator: [9, 48, 220, 101, 22, 240, 78, 200]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA)"]; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + relations: ["pool"]; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + relations: ["pool"]; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + relations: ["pool"]; + }, + { + name: "aVault"; + docs: [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ]; + relations: ["pool"]; + }, + { + name: "bVault"; + docs: [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ]; + relations: ["pool"]; + }, + { + name: "aVaultLpMint"; + docs: ["LP token mint of vault a"]; + }, + { + name: "bVaultLpMint"; + docs: ["LP token mint of vault b"]; + } + ]; + args: []; + }, + { + name: "initializeCustomizablePermissionlessConstantProductPool"; + docs: ["Initialize permissionless pool with customizable params"]; + discriminator: [145, 24, 172, 194, 219, 125, 3, 190]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA address)"]; + writable: true; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [108, 112, 95, 109, 105, 110, 116]; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "tokenAMint"; + docs: ["Token A mint of the pool. Eg: USDT"]; + }, + { + name: "tokenBMint"; + docs: ["Token B mint of the pool. Eg: USDC"]; + }, + { + name: "aVault"; + docs: [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + }, + { + name: "bVault"; + docs: [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + }, + { + name: "aTokenVault"; + docs: ["Token vault account of vault A"]; + writable: true; + }, + { + name: "bTokenVault"; + docs: ["Token vault account of vault B"]; + writable: true; + }, + { + name: "aVaultLpMint"; + docs: ["LP token mint of vault A"]; + writable: true; + }, + { + name: "bVaultLpMint"; + docs: ["LP token mint of vault B"]; + writable: true; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "aVault"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "bVault"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "payerTokenA"; + docs: [ + "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." + ]; + writable: true; + }, + { + name: "payerTokenB"; + docs: [ + "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." + ]; + writable: true; + }, + { + name: "payerPoolLp"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "payer"; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ]; + }, + { + kind: "account"; + path: "lpMint"; + } + ]; + program: { + kind: "const"; + value: [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ]; + }; + }; + }, + { + name: "protocolTokenAFee"; + docs: [ + "Protocol fee token account for token A. Used to receive trading fee." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [102, 101, 101]; + }, + { + kind: "account"; + path: "tokenAMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "protocolTokenBFee"; + docs: [ + "Protocol fee token account for token B. Used to receive trading fee." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [102, 101, 101]; + }, + { + kind: "account"; + path: "tokenBMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "payer"; + docs: [ + "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." + ]; + writable: true; + signer: true; + }, + { + name: "rent"; + docs: ["Rent account."]; + address: "SysvarRent111111111111111111111111111111111"; + }, + { + name: "mintMetadata"; + writable: true; + }, + { + name: "metadataProgram"; + }, + { + name: "vaultProgram"; + docs: [ + "Vault program. The pool will deposit/withdraw liquidity from the vault." + ]; + address: "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"; + }, + { + name: "tokenProgram"; + docs: ["Token program."]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "associatedTokenProgram"; + docs: ["Associated token program."]; + address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"; + }, + { + name: "systemProgram"; + docs: ["System program."]; + address: "11111111111111111111111111111111"; + } + ]; + args: [ + { + name: "tokenAAmount"; + type: "u64"; + }, + { + name: "tokenBAmount"; + type: "u64"; + }, + { + name: "params"; + type: { + defined: { + name: "customizableParams"; + }; + }; + } + ]; + }, + { + name: "initializePermissionedPool"; + docs: ["Initialize a new permissioned pool."]; + discriminator: [77, 85, 178, 157, 50, 48, 212, 126]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (arbitrary address)"]; + writable: true; + signer: true; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [108, 112, 95, 109, 105, 110, 116]; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "tokenAMint"; + docs: ["Token A mint of the pool. Eg: USDT"]; + }, + { + name: "tokenBMint"; + docs: ["Token B mint of the pool. Eg: USDC"]; + }, + { + name: "aVault"; + docs: [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + }, + { + name: "bVault"; + docs: [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + }, + { + name: "aVaultLpMint"; + docs: ["LP token mint of vault A"]; + writable: true; + }, + { + name: "bVaultLpMint"; + docs: ["LP token mint of vault B"]; + writable: true; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "aVault"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "bVault"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "adminTokenA"; + docs: [ + "Admin token account for pool token A mint. Used to bootstrap the pool with initial liquidity." + ]; + writable: true; + }, + { + name: "adminTokenB"; + docs: [ + "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." + ]; + writable: true; + }, + { + name: "adminPoolLp"; + docs: [ + "Admin pool LP token account. Used to receive LP during first deposit (initialize pool)", + "Admin pool LP token account. Used to receive LP during first deposit (initialize pool)" + ]; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "admin"; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ]; + }, + { + kind: "account"; + path: "lpMint"; + } + ]; + program: { + kind: "const"; + value: [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ]; + }; + }; + }, + { + name: "protocolTokenAFee"; + docs: [ + "Protocol fee token account for token A. Used to receive trading fee." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [102, 101, 101]; + }, + { + kind: "account"; + path: "tokenAMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "protocolTokenBFee"; + docs: [ + "Protocol fee token account for token B. Used to receive trading fee." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [102, 101, 101]; + }, + { + kind: "account"; + path: "tokenBMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "admin"; + docs: [ + "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." + ]; + writable: true; + signer: true; + }, + { + name: "feeOwner"; + }, + { + name: "rent"; + docs: ["Rent account."]; + address: "SysvarRent111111111111111111111111111111111"; + }, + { + name: "mintMetadata"; + writable: true; + }, + { + name: "metadataProgram"; + }, + { + name: "vaultProgram"; + docs: [ + "Vault program. The pool will deposit/withdraw liquidity from the vault." + ]; + address: "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"; + }, + { + name: "tokenProgram"; + docs: ["Token program."]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "associatedTokenProgram"; + docs: ["Associated token program."]; + address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"; + }, + { + name: "systemProgram"; + docs: ["System program."]; + address: "11111111111111111111111111111111"; + } + ]; + args: [ + { + name: "curveType"; + type: { + defined: { + name: "curveType"; + }; + }; + } + ]; + }, + { + name: "initializePermissionlessConstantProductPoolWithConfig"; + docs: ["Initialize permissionless pool with config"]; + discriminator: [7, 166, 138, 171, 206, 171, 236, 244]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA address)"]; + writable: true; + }, + { + name: "config"; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [108, 112, 95, 109, 105, 110, 116]; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "tokenAMint"; + docs: ["Token A mint of the pool. Eg: USDT"]; + }, + { + name: "tokenBMint"; + docs: ["Token B mint of the pool. Eg: USDC"]; + }, + { + name: "aVault"; + docs: [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + }, + { + name: "bVault"; + docs: [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + }, + { + name: "aTokenVault"; + docs: ["Token vault account of vault A"]; + writable: true; + }, + { + name: "bTokenVault"; + docs: ["Token vault account of vault B"]; + writable: true; + }, + { + name: "aVaultLpMint"; + docs: ["LP token mint of vault A"]; + writable: true; + }, + { + name: "bVaultLpMint"; + docs: ["LP token mint of vault B"]; + writable: true; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "aVault"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "bVault"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "payerTokenA"; + docs: [ + "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." + ]; + writable: true; + }, + { + name: "payerTokenB"; + docs: [ + "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." + ]; + writable: true; + }, + { + name: "payerPoolLp"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "payer"; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ]; + }, + { + kind: "account"; + path: "lpMint"; + } + ]; + program: { + kind: "const"; + value: [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ]; + }; + }; + }, + { + name: "protocolTokenAFee"; + docs: [ + "Protocol fee token account for token A. Used to receive trading fee." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [102, 101, 101]; + }, + { + kind: "account"; + path: "tokenAMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "protocolTokenBFee"; + docs: [ + "Protocol fee token account for token B. Used to receive trading fee." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [102, 101, 101]; + }, + { + kind: "account"; + path: "tokenBMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "payer"; + docs: [ + "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." + ]; + writable: true; + signer: true; + }, + { + name: "rent"; + docs: ["Rent account."]; + address: "SysvarRent111111111111111111111111111111111"; + }, + { + name: "mintMetadata"; + writable: true; + }, + { + name: "metadataProgram"; + }, + { + name: "vaultProgram"; + docs: [ + "Vault program. The pool will deposit/withdraw liquidity from the vault." + ]; + address: "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"; + }, + { + name: "tokenProgram"; + docs: ["Token program."]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "associatedTokenProgram"; + docs: ["Associated token program."]; + address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"; + }, + { + name: "systemProgram"; + docs: ["System program."]; + address: "11111111111111111111111111111111"; + } + ]; + args: [ + { + name: "tokenAAmount"; + type: "u64"; + }, + { + name: "tokenBAmount"; + type: "u64"; + } + ]; + }, + { + name: "initializePermissionlessConstantProductPoolWithConfig2"; + docs: ["Initialize permissionless pool with config 2"]; + discriminator: [48, 149, 220, 130, 61, 11, 9, 178]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA address)"]; + writable: true; + }, + { + name: "config"; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [108, 112, 95, 109, 105, 110, 116]; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "tokenAMint"; + docs: ["Token A mint of the pool. Eg: USDT"]; + }, + { + name: "tokenBMint"; + docs: ["Token B mint of the pool. Eg: USDC"]; + }, + { + name: "aVault"; + docs: [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + }, + { + name: "bVault"; + docs: [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + }, + { + name: "aTokenVault"; + docs: ["Token vault account of vault A"]; + writable: true; + }, + { + name: "bTokenVault"; + docs: ["Token vault account of vault B"]; + writable: true; + }, + { + name: "aVaultLpMint"; + docs: ["LP token mint of vault A"]; + writable: true; + }, + { + name: "bVaultLpMint"; + docs: ["LP token mint of vault B"]; + writable: true; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "aVault"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "bVault"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "payerTokenA"; + docs: [ + "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." + ]; + writable: true; + }, + { + name: "payerTokenB"; + docs: [ + "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." + ]; + writable: true; + }, + { + name: "payerPoolLp"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "payer"; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ]; + }, + { + kind: "account"; + path: "lpMint"; + } + ]; + program: { + kind: "const"; + value: [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ]; + }; + }; + }, + { + name: "protocolTokenAFee"; + docs: [ + "Protocol fee token account for token A. Used to receive trading fee." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [102, 101, 101]; + }, + { + kind: "account"; + path: "tokenAMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "protocolTokenBFee"; + docs: [ + "Protocol fee token account for token B. Used to receive trading fee." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [102, 101, 101]; + }, + { + kind: "account"; + path: "tokenBMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "payer"; + docs: [ + "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." + ]; + writable: true; + signer: true; + }, + { + name: "rent"; + docs: ["Rent account."]; + address: "SysvarRent111111111111111111111111111111111"; + }, + { + name: "mintMetadata"; + writable: true; + }, + { + name: "metadataProgram"; + }, + { + name: "vaultProgram"; + docs: [ + "Vault program. The pool will deposit/withdraw liquidity from the vault." + ]; + address: "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"; + }, + { + name: "tokenProgram"; + docs: ["Token program."]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "associatedTokenProgram"; + docs: ["Associated token program."]; + address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"; + }, + { + name: "systemProgram"; + docs: ["System program."]; + address: "11111111111111111111111111111111"; + } + ]; + args: [ + { + name: "tokenAAmount"; + type: "u64"; + }, + { + name: "tokenBAmount"; + type: "u64"; + }, + { + name: "activationPoint"; + type: { + option: "u64"; + }; + } + ]; + }, + { + name: "initializePermissionlessPool"; + docs: ["Initialize a new permissionless pool."]; + discriminator: [118, 173, 41, 157, 173, 72, 97, 103]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA address)"]; + writable: true; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [108, 112, 95, 109, 105, 110, 116]; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "tokenAMint"; + docs: ["Token A mint of the pool. Eg: USDT"]; + }, + { + name: "tokenBMint"; + docs: ["Token B mint of the pool. Eg: USDC"]; + }, + { + name: "aVault"; + docs: [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + }, + { + name: "bVault"; + docs: [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + }, + { + name: "aTokenVault"; + docs: ["Token vault account of vault A"]; + writable: true; + }, + { + name: "bTokenVault"; + docs: ["Token vault account of vault B"]; + writable: true; + }, + { + name: "aVaultLpMint"; + docs: ["LP token mint of vault A"]; + writable: true; + }, + { + name: "bVaultLpMint"; + docs: ["LP token mint of vault B"]; + writable: true; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "aVault"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "bVault"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "payerTokenA"; + docs: [ + "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." + ]; + writable: true; + }, + { + name: "payerTokenB"; + docs: [ + "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." + ]; + writable: true; + }, + { + name: "payerPoolLp"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "payer"; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ]; + }, + { + kind: "account"; + path: "lpMint"; + } + ]; + program: { + kind: "const"; + value: [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ]; + }; + }; + }, + { + name: "protocolTokenAFee"; + docs: [ + "Protocol fee token account for token A. Used to receive trading fee." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [102, 101, 101]; + }, + { + kind: "account"; + path: "tokenAMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "protocolTokenBFee"; + docs: [ + "Protocol fee token account for token B. Used to receive trading fee." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [102, 101, 101]; + }, + { + kind: "account"; + path: "tokenBMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "payer"; + docs: [ + "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." + ]; + writable: true; + signer: true; + }, + { + name: "feeOwner"; + }, + { + name: "rent"; + docs: ["Rent account."]; + address: "SysvarRent111111111111111111111111111111111"; + }, + { + name: "mintMetadata"; + writable: true; + }, + { + name: "metadataProgram"; + }, + { + name: "vaultProgram"; + docs: [ + "Vault program. The pool will deposit/withdraw liquidity from the vault." + ]; + address: "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"; + }, + { + name: "tokenProgram"; + docs: ["Token program."]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "associatedTokenProgram"; + docs: ["Associated token program."]; + address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"; + }, + { + name: "systemProgram"; + docs: ["System program."]; + address: "11111111111111111111111111111111"; + } + ]; + args: [ + { + name: "curveType"; + type: { + defined: { + name: "curveType"; + }; + }; + }, + { + name: "tokenAAmount"; + type: "u64"; + }, + { + name: "tokenBAmount"; + type: "u64"; + } + ]; + }, + { + name: "initializePermissionlessPoolWithFeeTier"; + docs: ["Initialize a new permissionless pool with customized fee tier"]; + discriminator: [6, 135, 68, 147, 229, 82, 169, 113]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA address)"]; + writable: true; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [108, 112, 95, 109, 105, 110, 116]; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "tokenAMint"; + docs: ["Token A mint of the pool. Eg: USDT"]; + }, + { + name: "tokenBMint"; + docs: ["Token B mint of the pool. Eg: USDC"]; + }, + { + name: "aVault"; + docs: [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + }, + { + name: "bVault"; + docs: [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + }, + { + name: "aTokenVault"; + docs: ["Token vault account of vault A"]; + writable: true; + }, + { + name: "bTokenVault"; + docs: ["Token vault account of vault B"]; + writable: true; + }, + { + name: "aVaultLpMint"; + docs: ["LP token mint of vault A"]; + writable: true; + }, + { + name: "bVaultLpMint"; + docs: ["LP token mint of vault B"]; + writable: true; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "aVault"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "bVault"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "payerTokenA"; + docs: [ + "Payer token account for pool token A mint. Used to bootstrap the pool with initial liquidity." + ]; + writable: true; + }, + { + name: "payerTokenB"; + docs: [ + "Admin token account for pool token B mint. Used to bootstrap the pool with initial liquidity." + ]; + writable: true; + }, + { + name: "payerPoolLp"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "payer"; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ]; + }, + { + kind: "account"; + path: "lpMint"; + } + ]; + program: { + kind: "const"; + value: [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ]; + }; + }; + }, + { + name: "protocolTokenAFee"; + docs: [ + "Protocol fee token account for token A. Used to receive trading fee." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [102, 101, 101]; + }, + { + kind: "account"; + path: "tokenAMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "protocolTokenBFee"; + docs: [ + "Protocol fee token account for token B. Used to receive trading fee." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [102, 101, 101]; + }, + { + kind: "account"; + path: "tokenBMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "payer"; + docs: [ + "Admin account. This account will be the admin of the pool, and the payer for PDA during initialize pool." + ]; + writable: true; + signer: true; + }, + { + name: "feeOwner"; + }, + { + name: "rent"; + docs: ["Rent account."]; + address: "SysvarRent111111111111111111111111111111111"; + }, + { + name: "mintMetadata"; + writable: true; + }, + { + name: "metadataProgram"; + }, + { + name: "vaultProgram"; + docs: [ + "Vault program. The pool will deposit/withdraw liquidity from the vault." + ]; + address: "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"; + }, + { + name: "tokenProgram"; + docs: ["Token program."]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "associatedTokenProgram"; + docs: ["Associated token program."]; + address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"; + }, + { + name: "systemProgram"; + docs: ["System program."]; + address: "11111111111111111111111111111111"; + } + ]; + args: [ + { + name: "curveType"; + type: { + defined: { + name: "curveType"; + }; + }; + }, + { + name: "tradeFeeBps"; + type: "u64"; + }, + { + name: "tokenAAmount"; + type: "u64"; + }, + { + name: "tokenBAmount"; + type: "u64"; + } + ]; + }, + { + name: "lock"; + docs: ["Lock Lp token"]; + discriminator: [21, 19, 208, 43, 237, 62, 255, 87]; + accounts: [ + { + name: "pool"; + docs: ["Pool account"]; + writable: true; + relations: ["lockEscrow"]; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + relations: ["pool"]; + }, + { + name: "lockEscrow"; + docs: ["Lock account"]; + writable: true; + }, + { + name: "owner"; + docs: ["Can be anyone"]; + writable: true; + signer: true; + }, + { + name: "sourceTokens"; + docs: ["owner lp token account"]; + writable: true; + }, + { + name: "escrowVault"; + docs: ["Escrow vault"]; + writable: true; + relations: ["lockEscrow"]; + }, + { + name: "tokenProgram"; + docs: ["Token program."]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "aVault"; + docs: [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ]; + relations: ["pool"]; + }, + { + name: "bVault"; + docs: [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ]; + relations: ["pool"]; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + relations: ["pool"]; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + relations: ["pool"]; + }, + { + name: "aVaultLpMint"; + docs: ["LP token mint of vault a"]; + }, + { + name: "bVaultLpMint"; + docs: ["LP token mint of vault b"]; + } + ]; + args: [ + { + name: "maxAmount"; + type: "u64"; + } + ]; + }, + { + name: "overrideCurveParam"; + docs: [ + "Update swap curve parameters. This function do not allow update of curve type. For example: stable swap curve to constant product curve. Only supported by pool with stable swap curve.", + "Only amp is allowed to be override. The other attributes of stable swap curve will be ignored." + ]; + discriminator: [98, 86, 204, 51, 94, 71, 69, 187]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA)"]; + writable: true; + }, + { + name: "admin"; + docs: ["Admin account."]; + signer: true; + } + ]; + args: [ + { + name: "curveType"; + type: { + defined: { + name: "curveType"; + }; + }; + } + ]; + }, + { + name: "partnerClaimFee"; + docs: ["Partner claim fee"]; + discriminator: [57, 53, 176, 30, 123, 70, 52, 64]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA)"]; + writable: true; + }, + { + name: "aVaultLp"; + relations: ["pool"]; + }, + { + name: "protocolTokenAFee"; + writable: true; + relations: ["pool"]; + }, + { + name: "protocolTokenBFee"; + writable: true; + relations: ["pool"]; + }, + { + name: "partnerTokenA"; + writable: true; + }, + { + name: "partnerTokenB"; + writable: true; + }, + { + name: "tokenProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "partnerAuthority"; + signer: true; + } + ]; + args: [ + { + name: "maxAmountA"; + type: "u64"; + }, + { + name: "maxAmountB"; + type: "u64"; + } + ]; + }, + { + name: "removeBalanceLiquidity"; + docs: [ + "Withdraw tokens from the pool in a balanced ratio. User will still able to withdraw from pool even the pool is disabled. This allow user to exit their liquidity when there's some unforeseen event happen." + ]; + discriminator: [133, 109, 44, 179, 56, 238, 114, 33]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA)"]; + writable: true; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + writable: true; + relations: ["pool"]; + }, + { + name: "userPoolLp"; + docs: [ + "user pool lp token account. lp will be burned from this account upon success liquidity removal." + ]; + writable: true; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "aVault"; + docs: [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "bVault"; + docs: [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "aVaultLpMint"; + docs: ["LP token mint of vault a"]; + writable: true; + }, + { + name: "bVaultLpMint"; + docs: ["LP token mint of vault b"]; + writable: true; + }, + { + name: "aTokenVault"; + docs: ["Token vault account of vault A"]; + writable: true; + }, + { + name: "bTokenVault"; + docs: ["Token vault account of vault B"]; + writable: true; + }, + { + name: "userAToken"; + docs: [ + "User token A account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ]; + writable: true; + }, + { + name: "userBToken"; + docs: [ + "User token B account. Token will be transfer from this account if it is add liquidity operation. Else, token will be transfer into this account." + ]; + writable: true; + }, + { + name: "user"; + docs: [ + "User account. Must be owner of user_a_token, and user_b_token." + ]; + signer: true; + }, + { + name: "vaultProgram"; + docs: [ + "Vault program. the pool will deposit/withdraw liquidity from the vault." + ]; + address: "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"; + }, + { + name: "tokenProgram"; + docs: ["Token program."]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + } + ]; + args: [ + { + name: "poolTokenAmount"; + type: "u64"; + }, + { + name: "minimumATokenOut"; + type: "u64"; + }, + { + name: "minimumBTokenOut"; + type: "u64"; + } + ]; + }, + { + name: "removeLiquiditySingleSide"; + docs: [ + "Withdraw only single token from the pool. Only supported by pool with stable swap curve." + ]; + discriminator: [84, 84, 177, 66, 254, 185, 10, 251]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA)"]; + writable: true; + }, + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + writable: true; + relations: ["pool"]; + }, + { + name: "userPoolLp"; + docs: [ + "User pool lp token account. LP will be burned from this account upon success liquidity removal." + ]; + writable: true; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "aVault"; + docs: [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "bVault"; + docs: [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "aVaultLpMint"; + docs: ["LP token mint of vault A"]; + writable: true; + }, + { + name: "bVaultLpMint"; + docs: ["LP token mint of vault B"]; + writable: true; + }, + { + name: "aTokenVault"; + docs: ["Token vault account of vault A"]; + writable: true; + }, + { + name: "bTokenVault"; + docs: ["Token vault account of vault B"]; + writable: true; + }, + { + name: "userDestinationToken"; + docs: [ + "User token account to receive token upon success liquidity removal." + ]; + writable: true; + }, + { + name: "user"; + docs: ["User account. Must be owner of the user_pool_lp account."]; + signer: true; + }, + { + name: "vaultProgram"; + docs: [ + "Vault program. The pool will deposit/withdraw liquidity from the vault." + ]; + address: "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"; + }, + { + name: "tokenProgram"; + docs: ["Token program."]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + } + ]; + args: [ + { + name: "poolTokenAmount"; + type: "u64"; + }, + { + name: "minimumOutAmount"; + type: "u64"; + } + ]; + }, + { + name: "setPoolFees"; + docs: ["Update trading fee charged for liquidity provider, and admin."]; + discriminator: [102, 44, 158, 54, 205, 37, 126, 78]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA)"]; + writable: true; + }, + { + name: "feeOperator"; + docs: ["Fee operator account"]; + signer: true; + } + ]; + args: [ + { + name: "fees"; + type: { + defined: { + name: "poolFees"; + }; + }; + }, + { + name: "newPartnerFeeNumerator"; + type: "u64"; + } + ]; + }, + { + name: "setWhitelistedVault"; + docs: ["Set whitelisted vault"]; + discriminator: [12, 148, 94, 42, 55, 57, 83, 247]; + accounts: [ + { + name: "pool"; + writable: true; + }, + { + name: "admin"; + signer: true; + } + ]; + args: [ + { + name: "whitelistedVault"; + type: "pubkey"; + } + ]; + }, + { + name: "swap"; + docs: [ + "Swap token A to B, or vice versa. An amount of trading fee will be charged for liquidity provider, and the admin of the pool." + ]; + discriminator: [248, 198, 158, 145, 225, 117, 135, 200]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA)"]; + writable: true; + }, + { + name: "userSourceToken"; + docs: [ + "User token account. Token from this account will be transfer into the vault by the pool in exchange for another token of the pool." + ]; + writable: true; + }, + { + name: "userDestinationToken"; + docs: [ + "User token account. The exchanged token will be transfer into this account from the pool." + ]; + writable: true; + }, + { + name: "aVault"; + docs: [ + "Vault account for token a. token a of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "bVault"; + docs: [ + "Vault account for token b. token b of the pool will be deposit / withdraw from this vault account." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "aTokenVault"; + docs: ["Token vault account of vault A"]; + writable: true; + }, + { + name: "bTokenVault"; + docs: ["Token vault account of vault B"]; + writable: true; + }, + { + name: "aVaultLpMint"; + docs: ["Lp token mint of vault a"]; + writable: true; + }, + { + name: "bVaultLpMint"; + docs: ["Lp token mint of vault b"]; + writable: true; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + writable: true; + relations: ["pool"]; + }, + { + name: "protocolTokenFee"; + docs: [ + "Protocol fee token account. Used to receive trading fee. It's mint field must matched with user_source_token mint field." + ]; + writable: true; + }, + { + name: "user"; + docs: ["User account. Must be owner of user_source_token."]; + signer: true; + }, + { + name: "vaultProgram"; + docs: [ + "Vault program. the pool will deposit/withdraw liquidity from the vault." + ]; + address: "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"; + }, + { + name: "tokenProgram"; + docs: ["Token program."]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + } + ]; + args: [ + { + name: "inAmount"; + type: "u64"; + }, + { + name: "minimumOutAmount"; + type: "u64"; + } + ]; + }, + { + name: "updateActivationPoint"; + docs: ["Update activation slot"]; + discriminator: [150, 62, 125, 219, 171, 220, 26, 237]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA)"]; + writable: true; + }, + { + name: "admin"; + docs: ["Admin account."]; + signer: true; + } + ]; + args: [ + { + name: "newActivationPoint"; + type: "u64"; + } + ]; + }, + { + name: "withdrawProtocolFees"; + docs: ["Withdraw protocol fee"]; + discriminator: [11, 68, 165, 98, 18, 208, 134, 73]; + accounts: [ + { + name: "pool"; + docs: ["Pool account (PDA)"]; + }, + { + name: "aVaultLp"; + relations: ["pool"]; + }, + { + name: "protocolTokenAFee"; + writable: true; + relations: ["pool"]; + }, + { + name: "protocolTokenBFee"; + writable: true; + relations: ["pool"]; + }, + { + name: "treasuryTokenA"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 48, + 9, + 89, + 123, + 106, + 114, + 131, + 251, + 50, + 173, + 254, + 250, + 10, + 80, + 160, + 84, + 143, + 100, + 81, + 249, + 134, + 112, + 30, + 213, + 50, + 166, + 239, + 78, + 53, + 175, + 188, + 85 + ]; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ]; + }, + { + kind: "account"; + path: "protocol_token_a_fee.mint"; + account: "tokenAccount"; + } + ]; + program: { + kind: "const"; + value: [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ]; + }; + }; + }, + { + name: "treasuryTokenB"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 48, + 9, + 89, + 123, + 106, + 114, + 131, + 251, + 50, + 173, + 254, + 250, + 10, + 80, + 160, + 84, + 143, + 100, + 81, + 249, + 134, + 112, + 30, + 213, + 50, + 166, + 239, + 78, + 53, + 175, + 188, + 85 + ]; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ]; + }, + { + kind: "account"; + path: "protocol_token_b_fee.mint"; + account: "tokenAccount"; + } + ]; + program: { + kind: "const"; + value: [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ]; + }; + }; + }, + { + name: "tokenProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + } + ]; + args: []; + }, + { + name: "zapProtocolFee"; + discriminator: [213, 155, 187, 34, 56, 182, 91, 240]; + accounts: [ + { + name: "pool"; + }, + { + name: "aVaultLp"; + relations: ["pool"]; + }, + { + name: "protocolTokenFee"; + writable: true; + }, + { + name: "tokenMint"; + }, + { + name: "receiverToken"; + writable: true; + }, + { + name: "operator"; + docs: ["zap claim fee operator"]; + }, + { + name: "signer"; + docs: ["operator"]; + signer: true; + }, + { + name: "tokenProgram"; + docs: ["Token program"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "sysvarInstructions"; + address: "Sysvar1nstructions1111111111111111111111111"; + } + ]; + args: [ + { + name: "maxAmount"; + type: "u64"; + } + ]; + } + ]; + accounts: [ + { + name: "config"; + discriminator: [155, 12, 170, 224, 30, 250, 204, 130]; + }, + { + name: "lockEscrow"; + discriminator: [190, 106, 121, 6, 200, 182, 21, 75]; + }, + { + name: "operator"; + discriminator: [219, 31, 188, 145, 69, 139, 204, 117]; + }, + { + name: "pool"; + discriminator: [241, 154, 109, 4, 17, 177, 109, 188]; + }, + { + name: "vault"; + discriminator: [211, 8, 232, 43, 2, 152, 117, 119]; + } + ]; + events: [ + { + name: "addLiquidity"; + discriminator: [31, 94, 125, 90, 227, 52, 61, 186]; + }, + { + name: "bootstrapLiquidity"; + discriminator: [121, 127, 38, 136, 92, 55, 14, 247]; + }, + { + name: "claimFee"; + discriminator: [75, 122, 154, 48, 140, 74, 123, 163]; + }, + { + name: "closeConfig"; + discriminator: [249, 181, 108, 89, 4, 150, 90, 174]; + }, + { + name: "createConfig"; + discriminator: [199, 152, 10, 19, 39, 39, 157, 104]; + }, + { + name: "createLockEscrow"; + discriminator: [74, 94, 106, 141, 49, 17, 98, 109]; + }, + { + name: "lock"; + discriminator: [220, 183, 67, 215, 153, 207, 56, 234]; + }, + { + name: "migrateFeeAccount"; + discriminator: [223, 234, 232, 26, 252, 105, 180, 125]; + }, + { + name: "overrideCurveParam"; + discriminator: [247, 20, 165, 248, 75, 5, 54, 246]; + }, + { + name: "partnerClaimFees"; + discriminator: [135, 131, 10, 94, 119, 209, 202, 48]; + }, + { + name: "poolCreated"; + discriminator: [202, 44, 41, 88, 104, 220, 157, 82]; + }, + { + name: "poolEnabled"; + discriminator: [2, 151, 18, 83, 204, 134, 92, 191]; + }, + { + name: "poolInfo"; + discriminator: [207, 20, 87, 97, 251, 212, 234, 45]; + }, + { + name: "removeLiquidity"; + discriminator: [116, 244, 97, 232, 103, 31, 152, 58]; + }, + { + name: "setPoolFees"; + discriminator: [245, 26, 198, 164, 88, 18, 75, 9]; + }, + { + name: "swap"; + discriminator: [81, 108, 227, 190, 205, 208, 10, 196]; + }, + { + name: "transferAdmin"; + discriminator: [228, 169, 131, 244, 61, 56, 65, 254]; + }, + { + name: "withdrawProtocolFees"; + discriminator: [30, 240, 207, 196, 139, 239, 79, 28]; + } + ]; + errors: [ + { + code: 6000; + name: "mathOverflow"; + msg: "Math operation overflow"; + }, + { + code: 6001; + name: "invalidFee"; + msg: "Invalid fee setup"; + }, + { + code: 6002; + name: "invalidInvariant"; + msg: "Invalid invariant d"; + }, + { + code: 6003; + name: "feeCalculationFailure"; + msg: "Fee calculation failure"; + }, + { + code: 6004; + name: "exceededSlippage"; + msg: "Exceeded slippage tolerance"; + }, + { + code: 6005; + name: "invalidCalculation"; + msg: "Invalid curve calculation"; + }, + { + code: 6006; + name: "zeroTradingTokens"; + msg: "Given pool token amount results in zero trading tokens"; + }, + { + code: 6007; + name: "conversionError"; + msg: "Math conversion overflow"; + }, + { + code: 6008; + name: "faultyLpMint"; + msg: "LP mint authority must be 'A' vault lp, without freeze authority, and 0 supply"; + }, + { + code: 6009; + name: "mismatchedTokenMint"; + msg: "Token mint mismatched"; + }, + { + code: 6010; + name: "mismatchedLpMint"; + msg: "LP mint mismatched"; + }, + { + code: 6011; + name: "mismatchedOwner"; + msg: "Invalid lp token owner"; + }, + { + code: 6012; + name: "invalidVaultAccount"; + msg: "Invalid vault account"; + }, + { + code: 6013; + name: "invalidVaultLpAccount"; + msg: "Invalid vault lp account"; + }, + { + code: 6014; + name: "invalidPoolLpMintAccount"; + msg: "Invalid pool lp mint account"; + }, + { + code: 6015; + name: "poolDisabled"; + msg: "Pool disabled"; + }, + { + code: 6016; + name: "invalidAdminAccount"; + msg: "Invalid admin account"; + }, + { + code: 6017; + name: "invalidProtocolFeeAccount"; + msg: "Invalid protocol fee account"; + }, + { + code: 6018; + name: "sameAdminAccount"; + msg: "Same admin account"; + }, + { + code: 6019; + name: "identicalSourceDestination"; + msg: "Identical user source and destination token account"; + }, + { + code: 6020; + name: "apyCalculationError"; + msg: "Apy calculation error"; + }, + { + code: 6021; + name: "insufficientSnapshot"; + msg: "Insufficient virtual price snapshot"; + }, + { + code: 6022; + name: "nonUpdatableCurve"; + msg: "Current curve is non-updatable"; + }, + { + code: 6023; + name: "misMatchedCurve"; + msg: "New curve is mismatched with old curve"; + }, + { + code: 6024; + name: "invalidAmplification"; + msg: "Amplification is invalid"; + }, + { + code: 6025; + name: "unsupportedOperation"; + msg: "Operation is not supported"; + }, + { + code: 6026; + name: "exceedMaxAChanges"; + msg: "Exceed max amplification changes"; + }, + { + code: 6027; + name: "invalidRemainingAccountsLen"; + msg: "Invalid remaining accounts length"; + }, + { + code: 6028; + name: "invalidRemainingAccounts"; + msg: "Invalid remaining account"; + }, + { + code: 6029; + name: "mismatchedDepegMint"; + msg: "Token mint B doesn't matches depeg type token mint"; + }, + { + code: 6030; + name: "invalidApyAccount"; + msg: "Invalid APY account"; + }, + { + code: 6031; + name: "invalidTokenMultiplier"; + msg: "Invalid token multiplier"; + }, + { + code: 6032; + name: "invalidDepegInformation"; + msg: "Invalid depeg information"; + }, + { + code: 6033; + name: "updateTimeConstraint"; + msg: "Update time constraint violated"; + }, + { + code: 6034; + name: "exceedMaxFeeBps"; + msg: "Exceeded max fee bps"; + }, + { + code: 6035; + name: "invalidAdmin"; + msg: "Invalid admin"; + }, + { + code: 6036; + name: "poolIsNotPermissioned"; + msg: "Pool is not permissioned"; + }, + { + code: 6037; + name: "invalidDepositAmount"; + msg: "Invalid deposit amount"; + }, + { + code: 6038; + name: "invalidFeeOwner"; + msg: "Invalid fee owner"; + }, + { + code: 6039; + name: "nonDepletedPool"; + msg: "Pool is not depleted"; + }, + { + code: 6040; + name: "amountNotPeg"; + msg: "Token amount is not 1:1"; + }, + { + code: 6041; + name: "amountIsZero"; + msg: "Amount is zero"; + }, + { + code: 6042; + name: "typeCastFailed"; + msg: "Type cast error"; + }, + { + code: 6043; + name: "amountIsNotEnough"; + msg: "Amount is not enough"; + }, + { + code: 6044; + name: "invalidActivationDuration"; + msg: "Invalid activation duration"; + }, + { + code: 6045; + name: "poolIsNotLaunchPool"; + msg: "Pool is not launch pool"; + }, + { + code: 6046; + name: "unableToModifyActivationPoint"; + msg: "Unable to modify activation point"; + }, + { + code: 6047; + name: "invalidAuthorityToCreateThePool"; + msg: "Invalid authority to create the pool"; + }, + { + code: 6048; + name: "invalidActivationType"; + msg: "Invalid activation type"; + }, + { + code: 6049; + name: "invalidActivationPoint"; + msg: "Invalid activation point"; + }, + { + code: 6050; + name: "preActivationSwapStarted"; + msg: "Pre activation swap window started"; + }, + { + code: 6051; + name: "invalidPoolType"; + msg: "Invalid pool type"; + }, + { + code: 6052; + name: "invalidQuoteMint"; + msg: "Quote token must be SOL,USDC"; + }, + { + code: 6053; + name: "invalidTokenMetadataProgram"; + msg: "Invalid token metadata program"; + }, + { + code: 6054; + name: "invalidPermission"; + msg: "Invalid permission"; + }, + { + code: 6055; + name: "invalidZapOutParameters"; + msg: "Invalid zap out parameters"; + }, + { + code: 6056; + name: "incorrectAta"; + msg: "Incorrect ATA"; + }, + { + code: 6057; + name: "invalidWithdrawProtocolFeeZapAccounts"; + msg: "Invalid withdraw protocol fee zap accounts"; + }, + { + code: 6058; + name: "mintRestrictedFromZap"; + msg: "SOL,USDC protocol fee cannot be withdrawn via zap"; + }, + { + code: 6059; + name: "cpiDisabled"; + msg: "CPI disabled"; + }, + { + code: 6060; + name: "missingZapOutInstruction"; + msg: "Missing zap out instruction"; + }, + { + code: 6061; + name: "invalidZapAccounts"; + msg: "Invalid zap accounts"; + } + ]; + types: [ + { + name: "addLiquidity"; + docs: ["Add liquidity event"]; + type: { + kind: "struct"; + fields: [ + { + name: "lpMintAmount"; + docs: ["LP amount user received upon add liquidity."]; + type: "u64"; + }, + { + name: "tokenAAmount"; + docs: ["Amount of token A user deposited."]; + type: "u64"; + }, + { + name: "tokenBAmount"; + docs: ["Amount of token B user deposited."]; + type: "u64"; + } + ]; + }; + }, + { + name: "bootstrapLiquidity"; + docs: ["Bootstrap liquidity event"]; + type: { + kind: "struct"; + fields: [ + { + name: "lpMintAmount"; + docs: ["LP amount user received upon add liquidity."]; + type: "u64"; + }, + { + name: "tokenAAmount"; + docs: ["Amount of token A user deposited."]; + type: "u64"; + }, + { + name: "tokenBAmount"; + docs: ["Amount of token B user deposited."]; + type: "u64"; + }, + { + name: "pool"; + docs: ["Pool address"]; + type: "pubkey"; + } + ]; + }; + }, + { + name: "bootstrapping"; + type: { + kind: "struct"; + fields: [ + { + name: "activationPoint"; + docs: ["Activation point, can be slot or timestamp"]; + type: "u64"; + }, + { + name: "whitelistedVault"; + docs: [ + "Whitelisted vault to be able to buy pool before activation_point" + ]; + type: "pubkey"; + }, + { + name: "poolCreator"; + docs: [ + "Need to store pool creator in lauch pool, so they can modify liquidity before activation_point" + ]; + type: "pubkey"; + }, + { + name: "activationType"; + docs: ["Activation type, 0 means by slot, 1 means by timestamp"]; + type: "u8"; + } + ]; + }; + }, + { + name: "claimFee"; + docs: ["Claim fee"]; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + docs: ["Pool address"]; + type: "pubkey"; + }, + { + name: "owner"; + docs: ["Owner of lock escrow"]; + type: "pubkey"; + }, + { + name: "amount"; + docs: ["Lp amount"]; + type: "u64"; + }, + { + name: "aFee"; + docs: ["A fee"]; + type: "u64"; + }, + { + name: "bFee"; + docs: ["B fee"]; + type: "u64"; + } + ]; + }; + }, + { + name: "closeConfig"; + docs: ["Close config"]; + type: { + kind: "struct"; + fields: [ + { + name: "config"; + docs: ["Config pubkey"]; + type: "pubkey"; + } + ]; + }; + }, + { + name: "config"; + type: { + kind: "struct"; + fields: [ + { + name: "poolFees"; + type: { + defined: { + name: "poolFees"; + }; + }; + }, + { + name: "activationDuration"; + type: "u64"; + }, + { + name: "vaultConfigKey"; + type: "pubkey"; + }, + { + name: "poolCreatorAuthority"; + docs: [ + "Only pool_creator_authority can use the current config to initialize new pool. When it's Pubkey::default, it's a public config." + ]; + type: "pubkey"; + }, + { + name: "activationType"; + docs: ["Activation type"]; + type: "u8"; + }, + { + name: "partnerFeeNumerator"; + type: "u64"; + }, + { + name: "padding"; + type: { + array: ["u8", 219]; + }; + } + ]; + }; + }, + { + name: "configParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "tradeFeeNumerator"; + type: "u64"; + }, + { + name: "protocolTradeFeeNumerator"; + type: "u64"; + }, + { + name: "activationDuration"; + type: "u64"; + }, + { + name: "vaultConfigKey"; + type: "pubkey"; + }, + { + name: "poolCreatorAuthority"; + type: "pubkey"; + }, + { + name: "activationType"; + type: "u8"; + }, + { + name: "index"; + type: "u64"; + }, + { + name: "partnerFeeNumerator"; + type: "u64"; + } + ]; + }; + }, + { + name: "createConfig"; + docs: ["Create config"]; + type: { + kind: "struct"; + fields: [ + { + name: "tradeFeeNumerator"; + docs: ["New trade fee numerator"]; + type: "u64"; + }, + { + name: "protocolTradeFeeNumerator"; + docs: ["New protocol fee numerator"]; + type: "u64"; + }, + { + name: "config"; + docs: ["Config pubkey"]; + type: "pubkey"; + } + ]; + }; + }, + { + name: "createLockEscrow"; + docs: ["Create lock escrow"]; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + docs: ["Pool address"]; + type: "pubkey"; + }, + { + name: "owner"; + docs: ["Owner of lock escrow"]; + type: "pubkey"; + } + ]; + }; + }, + { + name: "curveType"; + docs: ["Type of the swap curve"]; + type: { + kind: "enum"; + variants: [ + { + name: "constantProduct"; + }, + { + name: "stable"; + fields: [ + { + name: "amp"; + docs: ["Amplification coefficient"]; + type: "u64"; + }, + { + name: "tokenMultiplier"; + docs: [ + "Multiplier for the pool token. Used to normalized token with different decimal into the same precision." + ]; + type: { + defined: { + name: "tokenMultiplier"; + }; + }; + }, + { + name: "depeg"; + docs: [ + "Depeg pool information. Contains functions to allow token amount to be repeg using stake / interest bearing token virtual price" + ]; + type: { + defined: { + name: "depeg"; + }; + }; + }, + { + name: "lastAmpUpdatedTimestamp"; + docs: [ + "The last amp updated timestamp. Used to prevent update_curve_info called infinitely many times within a short period" + ]; + type: "u64"; + } + ]; + } + ]; + }; + }, + { + name: "customizableParams"; + type: { + kind: "struct"; + fields: [ + { + name: "tradeFeeNumerator"; + docs: ["Trading fee."]; + type: "u32"; + }, + { + name: "activationPoint"; + docs: ["The pool start trading."]; + type: { + option: "u64"; + }; + }, + { + name: "hasAlphaVault"; + docs: ["Whether the pool support alpha vault"]; + type: "bool"; + }, + { + name: "activationType"; + docs: ["Activation type"]; + type: "u8"; + }, + { + name: "padding"; + docs: ["padding"]; + type: { + array: ["u8", 90]; + }; + } + ]; + }; + }, + { + name: "depeg"; + docs: ["Contains information for depeg pool"]; + type: { + kind: "struct"; + fields: [ + { + name: "baseVirtualPrice"; + docs: ["The virtual price of staking / interest bearing token"]; + type: "u64"; + }, + { + name: "baseCacheUpdated"; + docs: ["The last time base_virtual_price is updated"]; + type: "u64"; + }, + { + name: "depegType"; + docs: ["Type of the depeg pool"]; + type: { + defined: { + name: "depegType"; + }; + }; + } + ]; + }; + }, + { + name: "depegType"; + docs: ["Type of depeg pool"]; + type: { + kind: "enum"; + variants: [ + { + name: "none"; + }, + { + name: "marinade"; + }, + { + name: "lido"; + }, + { + name: "splStake"; + } + ]; + }; + }, + { + name: "lock"; + docs: ["lock"]; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + docs: ["Pool address"]; + type: "pubkey"; + }, + { + name: "owner"; + docs: ["Owner of lock escrow"]; + type: "pubkey"; + }, + { + name: "amount"; + docs: ["Locked amount"]; + type: "u64"; + } + ]; + }; + }, + { + name: "lockEscrow"; + docs: ["State of lock escrow account"]; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + docs: ["Pool address"]; + type: "pubkey"; + }, + { + name: "owner"; + docs: ["Owner address"]; + type: "pubkey"; + }, + { + name: "escrowVault"; + docs: ["Vault address, store the lock user lock"]; + type: "pubkey"; + }, + { + name: "bump"; + docs: ["bump, used to sign"]; + type: "u8"; + }, + { + name: "totalLockedAmount"; + docs: ["Total locked amount"]; + type: "u64"; + }, + { + name: "lpPerToken"; + docs: ["Lp per token, virtual price of lp token"]; + type: "u128"; + }, + { + name: "unclaimedFeePending"; + docs: ["Unclaimed fee pending"]; + type: "u64"; + }, + { + name: "aFee"; + docs: ["Total a fee claimed so far"]; + type: "u64"; + }, + { + name: "bFee"; + docs: ["Total b fee claimed so far"]; + type: "u64"; + } + ]; + }; + }, + { + name: "lockedProfitTracker"; + docs: ["LockedProfitTracker struct"]; + type: { + kind: "struct"; + fields: [ + { + name: "lastUpdatedLockedProfit"; + docs: ["The total locked profit from the last report"]; + type: "u64"; + }, + { + name: "lastReport"; + docs: ["The last timestamp (in seconds) rebalancing"]; + type: "u64"; + }, + { + name: "lockedProfitDegradation"; + docs: ["Rate per second of degradation"]; + type: "u64"; + } + ]; + }; + }, + { + name: "migrateFeeAccount"; + docs: ["Migrate fee account event"]; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + docs: ["Pool address"]; + type: "pubkey"; + }, + { + name: "newAdminTokenAFee"; + docs: ["New admin token a fee"]; + type: "pubkey"; + }, + { + name: "newAdminTokenBFee"; + docs: ["New admin token b fee"]; + type: "pubkey"; + }, + { + name: "tokenAAmount"; + docs: ["Transfer token a fee amount"]; + type: "u64"; + }, + { + name: "tokenBAmount"; + docs: ["Transfer token b fee amount"]; + type: "u64"; + } + ]; + }; + }, + { + name: "operator"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "whitelistedAddress"; + type: "pubkey"; + }, + { + name: "permission"; + type: "u128"; + }, + { + name: "padding"; + type: { + array: ["u64", 2]; + }; + } + ]; + }; + }, + { + name: "overrideCurveParam"; + docs: ["Override curve param event"]; + type: { + kind: "struct"; + fields: [ + { + name: "newAmp"; + docs: ["The new amplification for stable curve"]; + type: "u64"; + }, + { + name: "updatedTimestamp"; + docs: ["Updated timestamp"]; + type: "u64"; + }, + { + name: "pool"; + docs: ["Pool address"]; + type: "pubkey"; + } + ]; + }; + }, + { + name: "padding"; + docs: ["Padding for future pool fields"]; + type: { + kind: "struct"; + fields: [ + { + name: "padding0"; + docs: ["Padding 0"]; + type: { + array: ["u8", 6]; + }; + }, + { + name: "padding1"; + docs: ["Padding 1"]; + type: { + array: ["u64", 21]; + }; + }, + { + name: "padding2"; + docs: ["Padding 2"]; + type: { + array: ["u64", 21]; + }; + } + ]; + }; + }, + { + name: "partnerClaimFees"; + docs: ["Partner claim fees"]; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + docs: ["Pool address"]; + type: "pubkey"; + }, + { + name: "feeA"; + docs: ["Fee B"]; + type: "u64"; + }, + { + name: "feeB"; + docs: ["Fee B"]; + type: "u64"; + }, + { + name: "partner"; + docs: ["Partner"]; + type: "pubkey"; + } + ]; + }; + }, + { + name: "partnerInfo"; + type: { + kind: "struct"; + fields: [ + { + name: "feeNumerator"; + type: "u64"; + }, + { + name: "partnerAuthority"; + type: "pubkey"; + }, + { + name: "pendingFeeA"; + type: "u64"; + }, + { + name: "pendingFeeB"; + type: "u64"; + } + ]; + }; + }, + { + name: "pool"; + docs: ["State of pool account"]; + type: { + kind: "struct"; + fields: [ + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + type: "pubkey"; + }, + { + name: "tokenAMint"; + docs: ["Token A mint of the pool. Eg: USDT"]; + type: "pubkey"; + }, + { + name: "tokenBMint"; + docs: ["Token B mint of the pool. Eg: USDC"]; + type: "pubkey"; + }, + { + name: "aVault"; + docs: [ + "Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account." + ]; + type: "pubkey"; + }, + { + name: "bVault"; + docs: [ + "Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account." + ]; + type: "pubkey"; + }, + { + name: "aVaultLp"; + docs: [ + "LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + type: "pubkey"; + }, + { + name: "bVaultLp"; + docs: [ + "LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault." + ]; + type: "pubkey"; + }, + { + name: "aVaultLpBump"; + docs: ['"A" vault lp bump. Used to create signer seeds.']; + type: "u8"; + }, + { + name: "enabled"; + docs: [ + "Flag to determine whether the pool is enabled, or disabled." + ]; + type: "bool"; + }, + { + name: "protocolTokenAFee"; + docs: [ + "Protocol fee token account for token A. Used to receive trading fee." + ]; + type: "pubkey"; + }, + { + name: "protocolTokenBFee"; + docs: [ + "Protocol fee token account for token B. Used to receive trading fee." + ]; + type: "pubkey"; + }, + { + name: "feeLastUpdatedAt"; + docs: ["Fee last updated timestamp"]; + type: "u64"; + }, + { + name: "padding0"; + type: { + array: ["u8", 24]; + }; + }, + { + name: "fees"; + docs: ["Store the fee charges setting."]; + type: { + defined: { + name: "poolFees"; + }; + }; + }, + { + name: "poolType"; + docs: ["Pool type"]; + type: { + defined: { + name: "poolType"; + }; + }; + }, + { + name: "stake"; + docs: ["Stake pubkey of SPL stake pool"]; + type: "pubkey"; + }, + { + name: "totalLockedLp"; + docs: ["Total locked lp token"]; + type: "u64"; + }, + { + name: "bootstrapping"; + docs: ["bootstrapping config"]; + type: { + defined: { + name: "bootstrapping"; + }; + }; + }, + { + name: "partnerInfo"; + type: { + defined: { + name: "partnerInfo"; + }; + }; + }, + { + name: "padding"; + docs: ["Padding for future pool field"]; + type: { + defined: { + name: "padding"; + }; + }; + }, + { + name: "curveType"; + docs: ["The type of the swap curve supported by the pool."]; + type: { + defined: { + name: "curveType"; + }; + }; + } + ]; + }; + }, + { + name: "poolCreated"; + docs: ["New pool created event"]; + type: { + kind: "struct"; + fields: [ + { + name: "lpMint"; + docs: ["LP token mint of the pool"]; + type: "pubkey"; + }, + { + name: "tokenAMint"; + docs: ["Token A mint of the pool. Eg: USDT"]; + type: "pubkey"; + }, + { + name: "tokenBMint"; + docs: ["Token B mint of the pool. Eg: USDC"]; + type: "pubkey"; + }, + { + name: "poolType"; + docs: ["Pool type"]; + type: { + defined: { + name: "poolType"; + }; + }; + }, + { + name: "pool"; + docs: ["Pool address"]; + type: "pubkey"; + } + ]; + }; + }, + { + name: "poolEnabled"; + docs: ["Pool enabled state change event"]; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + docs: ["Pool address"]; + type: "pubkey"; + }, + { + name: "enabled"; + docs: ["Pool enabled state"]; + type: "bool"; + } + ]; + }; + }, + { + name: "poolFees"; + docs: ["Information regarding fee charges"]; + type: { + kind: "struct"; + fields: [ + { + name: "tradeFeeNumerator"; + docs: [ + "Trade fees are extra token amounts that are held inside the token", + "accounts during a trade, making the value of liquidity tokens rise.", + "Trade fee numerator" + ]; + type: "u64"; + }, + { + name: "tradeFeeDenominator"; + docs: ["Trade fee denominator"]; + type: "u64"; + }, + { + name: "protocolTradeFeeNumerator"; + docs: [ + "Protocol trading fees are extra token amounts that are held inside the token", + "accounts during a trade, with the equivalent in pool tokens minted to", + "the protocol of the program.", + "Protocol trade fee numerator" + ]; + type: "u64"; + }, + { + name: "protocolTradeFeeDenominator"; + docs: ["Protocol trade fee denominator"]; + type: "u64"; + } + ]; + }; + }, + { + name: "poolInfo"; + docs: ["Pool info event"]; + type: { + kind: "struct"; + fields: [ + { + name: "tokenAAmount"; + docs: ["Total token A amount in the pool"]; + type: "u64"; + }, + { + name: "tokenBAmount"; + docs: ["Total token B amount in the pool"]; + type: "u64"; + }, + { + name: "virtualPrice"; + docs: ["Current virtual price"]; + type: "f64"; + }, + { + name: "currentTimestamp"; + docs: ["Current unix timestamp"]; + type: "u64"; + } + ]; + }; + }, + { + name: "poolType"; + docs: ["Pool type"]; + type: { + kind: "enum"; + variants: [ + { + name: "permissioned"; + }, + { + name: "permissionless"; + } + ]; + }; + }, + { + name: "removeLiquidity"; + docs: ["Remove liquidity event"]; + type: { + kind: "struct"; + fields: [ + { + name: "lpUnmintAmount"; + docs: ["LP amount burned from user upon add remove liquidity."]; + type: "u64"; + }, + { + name: "tokenAOutAmount"; + docs: ["Amount of token A user received."]; + type: "u64"; + }, + { + name: "tokenBOutAmount"; + docs: ["Amount of token B user received."]; + type: "u64"; + } + ]; + }; + }, + { + name: "setPoolFees"; + docs: ["Set pool fees event"]; + type: { + kind: "struct"; + fields: [ + { + name: "tradeFeeNumerator"; + docs: ["New trade fee numerator"]; + type: "u64"; + }, + { + name: "tradeFeeDenominator"; + docs: ["New trade fee denominator"]; + type: "u64"; + }, + { + name: "protocolTradeFeeNumerator"; + docs: ["New protocol fee numerator"]; + type: "u64"; + }, + { + name: "protocolTradeFeeDenominator"; + docs: ["New protocol fee denominator"]; + type: "u64"; + }, + { + name: "pool"; + docs: ["Pool address"]; + type: "pubkey"; + } + ]; + }; + }, + { + name: "swap"; + docs: ["Swap event"]; + type: { + kind: "struct"; + fields: [ + { + name: "inAmount"; + docs: [ + "Token amount user deposited to the pool for token exchange." + ]; + type: "u64"; + }, + { + name: "outAmount"; + docs: ["Token amount user received from the pool."]; + type: "u64"; + }, + { + name: "tradeFee"; + docs: ["Trading fee charged for liquidity provider."]; + type: "u64"; + }, + { + name: "protocolFee"; + docs: ["Trading fee charged for the protocol."]; + type: "u64"; + }, + { + name: "hostFee"; + docs: ["Host fee charged"]; + type: "u64"; + } + ]; + }; + }, + { + name: "tokenMultiplier"; + docs: [ + "Multiplier for the pool token. Used to normalized token with different decimal into the same precision." + ]; + type: { + kind: "struct"; + fields: [ + { + name: "tokenAMultiplier"; + docs: ["Multiplier for token A of the pool."]; + type: "u64"; + }, + { + name: "tokenBMultiplier"; + docs: ["Multiplier for token B of the pool."]; + type: "u64"; + }, + { + name: "precisionFactor"; + docs: [ + "Record the highest token decimal in the pool. For example, Token A is 6 decimal, token B is 9 decimal. This will save value of 9." + ]; + type: "u8"; + } + ]; + }; + }, + { + name: "transferAdmin"; + docs: ["Transfer admin event"]; + type: { + kind: "struct"; + fields: [ + { + name: "admin"; + docs: ["Old admin of the pool"]; + type: "pubkey"; + }, + { + name: "newAdmin"; + docs: ["New admin of the pool"]; + type: "pubkey"; + }, + { + name: "pool"; + docs: ["Pool address"]; + type: "pubkey"; + } + ]; + }; + }, + { + name: "vault"; + docs: ["Vault struct"]; + type: { + kind: "struct"; + fields: [ + { + name: "enabled"; + docs: [ + "The flag, if admin set enable = false, then the user can only withdraw and cannot deposit in the vault." + ]; + type: "u8"; + }, + { + name: "bumps"; + docs: ["Vault nonce, to create vault seeds"]; + type: { + defined: { + name: "vaultBumps"; + }; + }; + }, + { + name: "totalAmount"; + docs: [ + "The total liquidity of the vault, including remaining tokens in token_vault and the liquidity in all strategies." + ]; + type: "u64"; + }, + { + name: "tokenVault"; + docs: ["Token account, hold liquidity in vault reserve"]; + type: "pubkey"; + }, + { + name: "feeVault"; + docs: [ + "Hold lp token of vault, each time rebalance crank is called, vault calculate performance fee and mint corresponding lp token amount to fee_vault. fee_vault is owned by treasury address" + ]; + type: "pubkey"; + }, + { + name: "tokenMint"; + docs: ["Token mint that vault supports"]; + type: "pubkey"; + }, + { + name: "lpMint"; + docs: ["Lp mint of vault"]; + type: "pubkey"; + }, + { + name: "strategies"; + docs: [ + "The list of strategy addresses that vault supports, vault can support up to MAX_STRATEGY strategies at the same time." + ]; + type: { + array: ["pubkey", 30]; + }; + }, + { + name: "base"; + docs: ["The base address to create vault seeds"]; + type: "pubkey"; + }, + { + name: "admin"; + docs: ["Admin of vault"]; + type: "pubkey"; + }, + { + name: "operator"; + docs: [ + "Person who can send the crank. Operator can only send liquidity to strategies that admin defined, and claim reward to account of treasury address" + ]; + type: "pubkey"; + }, + { + name: "lockedProfitTracker"; + docs: ["Stores information for locked profit."]; + type: { + defined: { + name: "lockedProfitTracker"; + }; + }; + } + ]; + }; + }, + { + name: "vaultBumps"; + docs: ["Vault bumps struct"]; + type: { + kind: "struct"; + fields: [ + { + name: "vaultBump"; + docs: ["vaultBump"]; + type: "u8"; + }, + { + name: "tokenVaultBump"; + docs: ["tokenVaultBump"]; + type: "u8"; + } + ]; + }; + }, + { + name: "withdrawProtocolFees"; + docs: ["Withdraw protocol fees"]; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + docs: ["Pool address"]; + type: "pubkey"; + }, + { + name: "protocolAFee"; + docs: ["Protocol A fee"]; + type: "u64"; + }, + { + name: "protocolBFee"; + docs: ["Protocol B fee"]; + type: "u64"; + }, + { + name: "protocolAFeeOwner"; + docs: ["Protocol A fee owner"]; + type: "pubkey"; + }, + { + name: "protocolBFeeOwner"; + docs: ["Protocol B fee owner"]; + type: "pubkey"; + } + ]; + }; + } + ]; +}; diff --git a/tests/common/idl/vault.ts b/tests/common/idl/vault.ts new file mode 100644 index 0000000..65d06a3 --- /dev/null +++ b/tests/common/idl/vault.ts @@ -0,0 +1,1589 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/vault.json`. + */ +export type Vault = { + address: "24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"; + metadata: { + name: "vault"; + version: "0.9.4"; + spec: "0.1.0"; + description: "Created with Anchor"; + }; + docs: ["Program for vault"]; + instructions: [ + { + name: "addStrategy"; + docs: ["add a strategy"]; + discriminator: [64, 123, 127, 227, 192, 234, 198, 20]; + accounts: [ + { + name: "vault"; + docs: ["vault"]; + writable: true; + relations: ["strategy"]; + }, + { + name: "strategy"; + docs: ["strategy"]; + }, + { + name: "admin"; + docs: ["admin"]; + signer: true; + relations: ["vault"]; + } + ]; + args: []; + }, + { + name: "claimRewards"; + docs: ["claim rewards from a strategy"]; + discriminator: [4, 144, 132, 71, 116, 23, 151, 80]; + accounts: [ + { + name: "vault"; + docs: ["vault"]; + }, + { + name: "strategy"; + docs: ["strategy"]; + }, + { + name: "tokenProgram"; + docs: ["tokenProgram"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "tokenRewardAcc"; + docs: ["tokenRewardAcc"]; + writable: true; + }, + { + name: "operator"; + docs: ["operator"]; + signer: true; + } + ]; + args: []; + }, + { + name: "deposit"; + docs: ["user deposit liquidity to vault"]; + discriminator: [242, 35, 198, 137, 82, 225, 242, 182]; + accounts: [ + { + name: "vault"; + docs: ["vault"]; + writable: true; + }, + { + name: "tokenVault"; + docs: ["tokenVault"]; + writable: true; + relations: ["vault"]; + }, + { + name: "lpMint"; + docs: ["lpMint"]; + writable: true; + relations: ["vault"]; + }, + { + name: "userToken"; + docs: ["userToken"]; + writable: true; + }, + { + name: "userLp"; + docs: ["userLp"]; + writable: true; + }, + { + name: "user"; + docs: ["user"]; + signer: true; + }, + { + name: "tokenProgram"; + docs: ["tokenProgram"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + } + ]; + args: [ + { + name: "tokenAmount"; + type: "u64"; + }, + { + name: "minimumLpTokenAmount"; + type: "u64"; + } + ]; + }, + { + name: "depositStrategy"; + docs: ["deposit liquidity to a strategy"]; + discriminator: [246, 82, 57, 226, 131, 222, 253, 249]; + accounts: [ + { + name: "vault"; + docs: ["vault"]; + writable: true; + }, + { + name: "strategy"; + docs: ["strategy"]; + writable: true; + }, + { + name: "tokenVault"; + docs: ["tokenVault"]; + writable: true; + relations: ["vault"]; + }, + { + name: "feeVault"; + docs: ["feeVault"]; + writable: true; + relations: ["vault"]; + }, + { + name: "lpMint"; + docs: ["lpMint"]; + writable: true; + relations: ["vault"]; + }, + { + name: "strategyProgram"; + }, + { + name: "collateralVault"; + docs: ["collateralVault"]; + writable: true; + }, + { + name: "reserve"; + writable: true; + }, + { + name: "tokenProgram"; + docs: ["tokenProgram"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "operator"; + docs: ["operator"]; + signer: true; + } + ]; + args: [ + { + name: "amount"; + type: "u64"; + } + ]; + }, + { + name: "enableVault"; + docs: ["enable vault"]; + discriminator: [145, 82, 241, 156, 26, 154, 233, 211]; + accounts: [ + { + name: "vault"; + docs: ["Vault account"]; + writable: true; + }, + { + name: "admin"; + docs: ["Admin account"]; + signer: true; + relations: ["vault"]; + } + ]; + args: [ + { + name: "enabled"; + type: "u8"; + } + ]; + }, + { + name: "getUnlockedAmount"; + docs: ["get unlocked amount"]; + discriminator: [22, 184, 50, 213, 60, 168, 181, 227]; + accounts: [ + { + name: "vault"; + docs: ["Vault account"]; + } + ]; + args: []; + }, + { + name: "initialize"; + docs: ["initialize new vault"]; + discriminator: [175, 175, 109, 31, 13, 152, 155, 237]; + accounts: [ + { + name: "vault"; + docs: [ + "This is base account for all vault", + "No need base key now because we only allow 1 vault per token now", + "Vault account" + ]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [118, 97, 117, 108, 116]; + }, + { + kind: "account"; + path: "tokenMint"; + }, + { + kind: "const"; + value: [ + 245, + 105, + 223, + 222, + 32, + 35, + 51, + 89, + 141, + 199, + 215, + 75, + 29, + 148, + 184, + 98, + 71, + 121, + 193, + 248, + 47, + 30, + 37, + 166, + 91, + 110, + 78, + 248, + 163, + 190, + 155, + 155 + ]; + } + ]; + }; + }, + { + name: "payer"; + docs: ["Payer can be anyone"]; + writable: true; + signer: true; + }, + { + name: "tokenVault"; + docs: ["Token vault account"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116]; + }, + { + kind: "account"; + path: "vault"; + } + ]; + }; + }, + { + name: "tokenMint"; + docs: ["Token mint account"]; + }, + { + name: "lpMint"; + docs: ["LP mint account"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [108, 112, 95, 109, 105, 110, 116]; + }, + { + kind: "account"; + path: "vault"; + } + ]; + }; + }, + { + name: "rent"; + docs: ["rent"]; + address: "SysvarRent111111111111111111111111111111111"; + }, + { + name: "tokenProgram"; + docs: ["tokenProgram"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "systemProgram"; + docs: ["systemProgram"]; + address: "11111111111111111111111111111111"; + } + ]; + args: []; + }, + { + name: "initializeIdleVault"; + docs: ["initialize idle vault the vault that cannot be rebalanced"]; + discriminator: [100, 187, 43, 147, 149, 180, 117, 223]; + accounts: [ + { + name: "vault"; + docs: ["Vault account"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [118, 97, 117, 108, 116]; + }, + { + kind: "account"; + path: "tokenMint"; + }, + { + kind: "const"; + value: [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ]; + } + ]; + }; + }, + { + name: "payer"; + docs: ["Payer can be anyone"]; + writable: true; + signer: true; + }, + { + name: "tokenVault"; + docs: ["Token vault account"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116]; + }, + { + kind: "account"; + path: "vault"; + } + ]; + }; + }, + { + name: "tokenMint"; + docs: ["Token mint account"]; + }, + { + name: "lpMint"; + docs: ["LP mint"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [108, 112, 95, 109, 105, 110, 116]; + }, + { + kind: "account"; + path: "vault"; + } + ]; + }; + }, + { + name: "rent"; + docs: ["rent"]; + address: "SysvarRent111111111111111111111111111111111"; + }, + { + name: "tokenProgram"; + docs: ["tokenProgram"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "systemProgram"; + docs: ["systemProgram"]; + address: "11111111111111111111111111111111"; + } + ]; + args: []; + }, + { + name: "initializeStrategy"; + docs: [ + "Initialize a strategy and add strategy to vault.strategies index" + ]; + discriminator: [208, 119, 144, 145, 178, 57, 105, 252]; + accounts: [ + { + name: "vault"; + docs: ["Vault account"]; + writable: true; + }, + { + name: "strategyProgram"; + }, + { + name: "strategy"; + docs: ["Strategy account"]; + writable: true; + }, + { + name: "reserve"; + writable: true; + }, + { + name: "collateralVault"; + docs: ["Collateral vault account"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 99, + 111, + 108, + 108, + 97, + 116, + 101, + 114, + 97, + 108, + 95, + 118, + 97, + 117, + 108, + 116 + ]; + }, + { + kind: "account"; + path: "strategy"; + } + ]; + }; + }, + { + name: "collateralMint"; + docs: ["Collateral mint account"]; + }, + { + name: "admin"; + docs: ["Admin account"]; + writable: true; + signer: true; + relations: ["vault"]; + }, + { + name: "systemProgram"; + docs: ["System program account"]; + address: "11111111111111111111111111111111"; + }, + { + name: "rent"; + docs: ["Rent account"]; + address: "SysvarRent111111111111111111111111111111111"; + }, + { + name: "tokenProgram"; + docs: ["Token program account"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + } + ]; + args: [ + { + name: "bumps"; + type: { + defined: { + name: "strategyBumps"; + }; + }; + }, + { + name: "strategyType"; + type: { + defined: { + name: "strategyType"; + }; + }; + } + ]; + }, + { + name: "removeStrategy"; + docs: ["remove a strategy"]; + discriminator: [185, 238, 33, 91, 134, 210, 97, 26]; + accounts: [ + { + name: "vault"; + docs: ["Vault account"]; + writable: true; + }, + { + name: "strategy"; + docs: ["Strategy account"]; + writable: true; + }, + { + name: "strategyProgram"; + }, + { + name: "collateralVault"; + docs: ["Collateral vault account"]; + writable: true; + }, + { + name: "reserve"; + writable: true; + }, + { + name: "tokenVault"; + docs: ["tokenVault"]; + writable: true; + relations: ["vault"]; + }, + { + name: "feeVault"; + docs: ["feeVault"]; + writable: true; + relations: ["vault"]; + }, + { + name: "lpMint"; + docs: ["lpMint"]; + writable: true; + relations: ["vault"]; + }, + { + name: "tokenProgram"; + docs: ["tokenProgram"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "admin"; + docs: ["admin"]; + signer: true; + relations: ["vault"]; + } + ]; + args: []; + }, + { + name: "removeStrategy2"; + docs: ["remove a strategy by advance payment"]; + discriminator: [138, 104, 208, 148, 126, 35, 195, 14]; + accounts: [ + { + name: "vault"; + docs: ["Vault account"]; + writable: true; + }, + { + name: "strategy"; + docs: ["Strategy account"]; + writable: true; + }, + { + name: "strategyProgram"; + }, + { + name: "collateralVault"; + docs: ["Collateral vault account"]; + writable: true; + }, + { + name: "reserve"; + writable: true; + }, + { + name: "tokenVault"; + docs: ["tokenVault"]; + writable: true; + relations: ["vault"]; + }, + { + name: "tokenAdminAdvancePayment"; + docs: [ + "token_advance_payment", + "the owner of token_advance_payment must be admin" + ]; + writable: true; + }, + { + name: "tokenVaultAdvancePayment"; + docs: [ + "tokenVaultAdvancePayment", + "the account must be different from token_vault and strategy's related token account", + "the owner of token_advance_payment must be vault" + ]; + writable: true; + }, + { + name: "feeVault"; + docs: ["feeVault"]; + writable: true; + relations: ["vault"]; + }, + { + name: "lpMint"; + docs: ["lpMint"]; + writable: true; + relations: ["vault"]; + }, + { + name: "tokenProgram"; + docs: ["tokenProgram"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "admin"; + docs: ["admin"]; + signer: true; + relations: ["vault"]; + } + ]; + args: [ + { + name: "maxAdminPayAmount"; + type: "u64"; + } + ]; + }, + { + name: "setOperator"; + docs: ["set new operator"]; + discriminator: [238, 153, 101, 169, 243, 131, 36, 1]; + accounts: [ + { + name: "vault"; + docs: ["Vault account"]; + writable: true; + }, + { + name: "operator"; + }, + { + name: "admin"; + docs: ["admin"]; + signer: true; + relations: ["vault"]; + } + ]; + args: []; + }, + { + name: "transferAdmin"; + docs: ["transfer admin"]; + discriminator: [42, 242, 66, 106, 228, 10, 111, 156]; + accounts: [ + { + name: "vault"; + docs: ["Vault account"]; + writable: true; + }, + { + name: "admin"; + docs: ["Admin account"]; + signer: true; + relations: ["vault"]; + }, + { + name: "newAdmin"; + docs: ["New vault admin"]; + signer: true; + } + ]; + args: []; + }, + { + name: "transferFeeVault"; + docs: ["transfer fee account"]; + discriminator: [24, 18, 129, 149, 149, 32, 45, 105]; + accounts: [ + { + name: "vault"; + docs: ["Vault account"]; + writable: true; + }, + { + name: "admin"; + docs: ["Admin account"]; + signer: true; + relations: ["vault"]; + }, + { + name: "newFeeVault"; + docs: ["New fee vault account"]; + } + ]; + args: []; + }, + { + name: "updateLockedProfitDegradation"; + docs: ["update locked profit degradation"]; + discriminator: [103, 192, 9, 190, 43, 209, 235, 115]; + accounts: [ + { + name: "vault"; + docs: ["Vault account"]; + writable: true; + }, + { + name: "admin"; + docs: ["Admin account"]; + signer: true; + relations: ["vault"]; + } + ]; + args: [ + { + name: "lockedProfitDegradation"; + type: "u64"; + } + ]; + }, + { + name: "withdraw"; + docs: ["user withdraw liquidity from vault"]; + discriminator: [183, 18, 70, 156, 148, 109, 161, 34]; + accounts: [ + { + name: "vault"; + docs: ["vault"]; + writable: true; + }, + { + name: "tokenVault"; + docs: ["tokenVault"]; + writable: true; + relations: ["vault"]; + }, + { + name: "lpMint"; + docs: ["lpMint"]; + writable: true; + relations: ["vault"]; + }, + { + name: "userToken"; + docs: ["userToken"]; + writable: true; + }, + { + name: "userLp"; + docs: ["userLp"]; + writable: true; + }, + { + name: "user"; + docs: ["user"]; + signer: true; + }, + { + name: "tokenProgram"; + docs: ["tokenProgram"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + } + ]; + args: [ + { + name: "unmintAmount"; + type: "u64"; + }, + { + name: "minOutAmount"; + type: "u64"; + } + ]; + }, + { + name: "withdrawDirectlyFromStrategy"; + docs: [ + "user withdraw liquidity from vault, if vault reserve doesn't have enough liquidity, it will withdraw from the strategy firstly" + ]; + discriminator: [201, 141, 146, 46, 173, 116, 198, 22]; + accounts: [ + { + name: "vault"; + docs: ["vault"]; + writable: true; + }, + { + name: "strategy"; + docs: ["strategy"]; + writable: true; + }, + { + name: "reserve"; + writable: true; + }, + { + name: "strategyProgram"; + }, + { + name: "collateralVault"; + docs: ["collateralVault"]; + writable: true; + }, + { + name: "tokenVault"; + docs: ["tokenVault"]; + writable: true; + relations: ["vault"]; + }, + { + name: "lpMint"; + docs: ["lpMint"]; + writable: true; + relations: ["vault"]; + }, + { + name: "feeVault"; + docs: ["feeVault"]; + writable: true; + relations: ["vault"]; + }, + { + name: "userToken"; + docs: ["userToken"]; + writable: true; + }, + { + name: "userLp"; + docs: ["userLp"]; + writable: true; + }, + { + name: "user"; + docs: ["user"]; + signer: true; + }, + { + name: "tokenProgram"; + docs: ["tokenProgram"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + } + ]; + args: [ + { + name: "unmintAmount"; + type: "u64"; + }, + { + name: "minOutAmount"; + type: "u64"; + } + ]; + }, + { + name: "withdrawStrategy"; + docs: ["withdraw liquidity from a strategy"]; + discriminator: [31, 45, 162, 5, 193, 217, 134, 188]; + accounts: [ + { + name: "vault"; + docs: ["vault"]; + writable: true; + }, + { + name: "strategy"; + docs: ["strategy"]; + writable: true; + }, + { + name: "tokenVault"; + docs: ["tokenVault"]; + writable: true; + relations: ["vault"]; + }, + { + name: "feeVault"; + docs: ["feeVault"]; + writable: true; + relations: ["vault"]; + }, + { + name: "lpMint"; + docs: ["lpMint"]; + writable: true; + relations: ["vault"]; + }, + { + name: "strategyProgram"; + }, + { + name: "collateralVault"; + docs: ["collateralVault"]; + writable: true; + }, + { + name: "reserve"; + writable: true; + }, + { + name: "tokenProgram"; + docs: ["tokenProgram"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "operator"; + docs: ["operator"]; + signer: true; + } + ]; + args: [ + { + name: "amount"; + type: "u64"; + } + ]; + } + ]; + accounts: [ + { + name: "strategy"; + discriminator: [174, 110, 39, 119, 82, 106, 169, 102]; + }, + { + name: "vault"; + discriminator: [211, 8, 232, 43, 2, 152, 117, 119]; + } + ]; + events: [ + { + name: "addLiquidity"; + discriminator: [31, 94, 125, 90, 227, 52, 61, 186]; + }, + { + name: "claimReward"; + discriminator: [148, 116, 134, 204, 22, 171, 85, 95]; + }, + { + name: "performanceFee"; + discriminator: [28, 70, 231, 223, 81, 109, 239, 167]; + }, + { + name: "removeLiquidity"; + discriminator: [116, 244, 97, 232, 103, 31, 152, 58]; + }, + { + name: "reportLoss"; + discriminator: [154, 36, 158, 196, 32, 163, 123, 126]; + }, + { + name: "strategyDeposit"; + discriminator: [205, 53, 91, 239, 34, 136, 73, 47]; + }, + { + name: "strategyWithdraw"; + discriminator: [120, 76, 208, 95, 221, 210, 229, 189]; + }, + { + name: "totalAmount"; + discriminator: [92, 200, 122, 145, 211, 203, 49, 205]; + } + ]; + errors: [ + { + code: 6000; + name: "vaultIsDisabled"; + msg: "Vault is disabled"; + }, + { + code: 6001; + name: "exceededSlippage"; + msg: "Exceeded slippage tolerance"; + }, + { + code: 6002; + name: "strategyIsNotExisted"; + msg: "Strategy is not existed"; + }, + { + code: 6003; + name: "unAuthorized"; + msg: "unAuthorized"; + }, + { + code: 6004; + name: "mathOverflow"; + msg: "Math operation overflow"; + }, + { + code: 6005; + name: "protocolIsNotSupported"; + msg: "Protocol is not supported"; + }, + { + code: 6006; + name: "unMatchReserve"; + msg: "Reserve does not support token mint"; + }, + { + code: 6007; + name: "invalidLockedProfitDegradation"; + msg: "lockedProfitDegradation is invalid"; + }, + { + code: 6008; + name: "maxStrategyReached"; + msg: "Maximum number of strategies have been reached"; + }, + { + code: 6009; + name: "strategyExisted"; + msg: "Strategy existed"; + }, + { + code: 6010; + name: "invalidUnmintAmount"; + msg: "Invalid unmint amount"; + }, + { + code: 6011; + name: "invalidAccountsForStrategy"; + msg: "Invalid accounts for strategy"; + }, + { + code: 6012; + name: "invalidBump"; + msg: "Invalid bump"; + }, + { + code: 6013; + name: "amountMustGreaterThanZero"; + msg: "Amount must be greater than 0"; + }, + { + code: 6014; + name: "mangoIsNotSupportedAnymore"; + msg: "Mango is not supported anymore"; + }, + { + code: 6015; + name: "strategyIsNotSupported"; + msg: "Strategy is not supported"; + }, + { + code: 6016; + name: "payAmountIsExceeded"; + msg: "Pay amount is exceeded"; + }, + { + code: 6017; + name: "feeVaultIsNotSet"; + msg: "Fee vault is not set"; + }, + { + code: 6018; + name: "lendingAssertionViolation"; + msg: "deposit amount in lending is not matched"; + }, + { + code: 6019; + name: "haveMoneyInLending"; + msg: "Cannot remove strategy because we have some in lending"; + }, + { + code: 6020; + name: "invalidPrecisionLoss"; + msg: "Invalid precision loss"; + }, + { + code: 6021; + name: "undeterminedError"; + msg: "Undetermined error"; + } + ]; + types: [ + { + name: "addLiquidity"; + docs: ["AddLiquidity event"]; + type: { + kind: "struct"; + fields: [ + { + name: "lpMintAmount"; + docs: ["lpMintAmount"]; + type: "u64"; + }, + { + name: "tokenAmount"; + docs: ["tokenAmount"]; + type: "u64"; + } + ]; + }; + }, + { + name: "claimReward"; + docs: ["ClaimReward event"]; + type: { + kind: "struct"; + fields: [ + { + name: "strategyType"; + docs: ["strategyType"]; + type: { + defined: { + name: "strategyType"; + }; + }; + }, + { + name: "tokenAmount"; + docs: ["tokenAmount"]; + type: "u64"; + }, + { + name: "mintAccount"; + docs: ["mintAccount"]; + type: "pubkey"; + } + ]; + }; + }, + { + name: "lockedProfitTracker"; + docs: ["LockedProfitTracker struct"]; + type: { + kind: "struct"; + fields: [ + { + name: "lastUpdatedLockedProfit"; + docs: ["The total locked profit from the last report"]; + type: "u64"; + }, + { + name: "lastReport"; + docs: ["The last timestamp (in seconds) rebalancing"]; + type: "u64"; + }, + { + name: "lockedProfitDegradation"; + docs: ["Rate per second of degradation"]; + type: "u64"; + } + ]; + }; + }, + { + name: "performanceFee"; + docs: ["PerformanceFee event"]; + type: { + kind: "struct"; + fields: [ + { + name: "lpMintMore"; + docs: ["lpMintMore"]; + type: "u64"; + } + ]; + }; + }, + { + name: "removeLiquidity"; + docs: ["RemoveLiquidity event"]; + type: { + kind: "struct"; + fields: [ + { + name: "lpUnmintAmount"; + docs: ["lpUnmintAmount"]; + type: "u64"; + }, + { + name: "tokenAmount"; + docs: ["tokenAmount"]; + type: "u64"; + } + ]; + }; + }, + { + name: "reportLoss"; + docs: ["ReportLoss event"]; + type: { + kind: "struct"; + fields: [ + { + name: "strategy"; + docs: ["strategy"]; + type: "pubkey"; + }, + { + name: "loss"; + docs: ["loss"]; + type: "u64"; + } + ]; + }; + }, + { + name: "strategy"; + docs: ["Strategy struct"]; + type: { + kind: "struct"; + fields: [ + { + name: "reserve"; + docs: [ + "Lending pool address, that the strategy will deposit/withdraw balance" + ]; + type: "pubkey"; + }, + { + name: "collateralVault"; + docs: ["The token account, that holds the collateral token"]; + type: "pubkey"; + }, + { + name: "strategyType"; + docs: ["Specify type of strategy"]; + type: { + defined: { + name: "strategyType"; + }; + }; + }, + { + name: "currentLiquidity"; + docs: [ + "The liquidity in strategy at the time vault deposit/withdraw from a lending protocol" + ]; + type: "u64"; + }, + { + name: "bumps"; + docs: [ + "Hold some bumps, in case the strategy needs to use other seeds to sign a CPI call." + ]; + type: { + array: ["u8", 10]; + }; + }, + { + name: "vault"; + docs: ["Vault address, that the strategy belongs"]; + type: "pubkey"; + }, + { + name: "isDisable"; + docs: [ + "If we remove strategy by remove_strategy2 endpoint, this account will be never added again" + ]; + type: "u8"; + } + ]; + }; + }, + { + name: "strategyBumps"; + docs: ["Strategy bumps struct"]; + type: { + kind: "struct"; + fields: [ + { + name: "strategyIndex"; + docs: ["strategyIndex"]; + type: "u8"; + }, + { + name: "otherBumps"; + docs: ["Bumps of PDAs for the integrated protocol."]; + type: { + array: ["u8", 10]; + }; + } + ]; + }; + }, + { + name: "strategyDeposit"; + docs: ["StrategyDeposit event"]; + type: { + kind: "struct"; + fields: [ + { + name: "strategyType"; + docs: ["strategyType"]; + type: { + defined: { + name: "strategyType"; + }; + }; + }, + { + name: "tokenAmount"; + docs: ["tokenAmount"]; + type: "u64"; + } + ]; + }; + }, + { + name: "strategyType"; + docs: ["StrategyType struct"]; + type: { + kind: "enum"; + variants: [ + { + name: "portFinanceWithoutLm"; + }, + { + name: "portFinanceWithLm"; + }, + { + name: "solendWithoutLm"; + }, + { + name: "mango"; + }, + { + name: "solendWithLm"; + }, + { + name: "apricotWithoutLm"; + }, + { + name: "francium"; + }, + { + name: "tulip"; + }, + { + name: "vault"; + }, + { + name: "drift"; + }, + { + name: "frakt"; + }, + { + name: "marginfi"; + }, + { + name: "kamino"; + }, + { + name: "jupLend"; + } + ]; + }; + }, + { + name: "strategyWithdraw"; + docs: ["StrategyWithdraw event"]; + type: { + kind: "struct"; + fields: [ + { + name: "strategyType"; + docs: ["strategyType"]; + type: { + defined: { + name: "strategyType"; + }; + }; + }, + { + name: "collateralAmount"; + docs: ["collateralAmount"]; + type: "u64"; + }, + { + name: "estimatedTokenAmount"; + docs: ["estimatedTokenAmount"]; + type: "u64"; + } + ]; + }; + }, + { + name: "totalAmount"; + docs: ["TotalAmount event"]; + type: { + kind: "struct"; + fields: [ + { + name: "totalAmount"; + docs: ["totalAmount"]; + type: "u64"; + } + ]; + }; + }, + { + name: "vault"; + docs: ["Vault struct"]; + type: { + kind: "struct"; + fields: [ + { + name: "enabled"; + docs: [ + "The flag, if admin set enable = false, then the user can only withdraw and cannot deposit in the vault." + ]; + type: "u8"; + }, + { + name: "bumps"; + docs: ["Vault nonce, to create vault seeds"]; + type: { + defined: { + name: "vaultBumps"; + }; + }; + }, + { + name: "totalAmount"; + docs: [ + "The total liquidity of the vault, including remaining tokens in token_vault and the liquidity in all strategies." + ]; + type: "u64"; + }, + { + name: "tokenVault"; + docs: ["Token account, hold liquidity in vault reserve"]; + type: "pubkey"; + }, + { + name: "feeVault"; + docs: [ + "Hold lp token of vault, each time rebalance crank is called, vault calculate performance fee and mint corresponding lp token amount to fee_vault. fee_vault is owned by treasury address" + ]; + type: "pubkey"; + }, + { + name: "tokenMint"; + docs: ["Token mint that vault supports"]; + type: "pubkey"; + }, + { + name: "lpMint"; + docs: ["Lp mint of vault"]; + type: "pubkey"; + }, + { + name: "strategies"; + docs: [ + "The list of strategy addresses that vault supports, vault can support up to MAX_STRATEGY strategies at the same time." + ]; + type: { + array: ["pubkey", 30]; + }; + }, + { + name: "base"; + docs: ["The base address to create vault seeds"]; + type: "pubkey"; + }, + { + name: "admin"; + docs: ["Admin of vault"]; + type: "pubkey"; + }, + { + name: "operator"; + docs: [ + "Person who can send the crank. Operator can only send liquidity to strategies that admin defined, and claim reward to account of treasury address" + ]; + type: "pubkey"; + }, + { + name: "lockedProfitTracker"; + docs: ["Stores information for locked profit."]; + type: { + defined: { + name: "lockedProfitTracker"; + }; + }; + } + ]; + }; + }, + { + name: "vaultBumps"; + docs: ["Vault bumps struct"]; + type: { + kind: "struct"; + fields: [ + { + name: "vaultBump"; + docs: ["vaultBump"]; + type: "u8"; + }, + { + name: "tokenVaultBump"; + docs: ["tokenVaultBump"]; + type: "u8"; + } + ]; + }; + } + ]; +}; diff --git a/tests/common/utils.ts b/tests/common/utils.ts index 8cdc070..2023734 100644 --- a/tests/common/utils.ts +++ b/tests/common/utils.ts @@ -253,3 +253,18 @@ export function warpSlotBy(svm: LiteSVM, slots: BN) { const clock = svm.getClock(); svm.warpToSlot(clock.slot + BigInt(slots.toString())); } + +export function sendTransaction( + svm: LiteSVM, + transaction: Transaction, + signers: Keypair[] +) { + transaction.recentBlockhash = svm.latestBlockhash(); + transaction.sign(...signers); + const result = svm.sendTransaction(transaction); + if (result instanceof FailedTransactionMetadata) { + console.log(result.meta().logs()); + } + expect(result).instanceOf(TransactionMetadata); + svm.expireBlockhash(); +} diff --git a/tests/common/vault.ts b/tests/common/vault.ts new file mode 100644 index 0000000..d5dbf26 --- /dev/null +++ b/tests/common/vault.ts @@ -0,0 +1,163 @@ +import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; +import { + clusterApiUrl, + Connection, + Keypair, + PublicKey, + SystemProgram, + SYSVAR_RENT_PUBKEY, +} from "@solana/web3.js"; +import { LiteSVM } from "litesvm"; +import type { Vault } from "./idl/vault"; +import VaultIDL from "../../idls/mercurial_vault.json"; +import { + AnchorProvider, + BN, + IdlAccounts, + Program, + Wallet, +} from "@coral-xyz/anchor"; +import { getOrCreateAtA, sendTransaction } from "./utils"; + +export function createVaultProgram() { + const wallet = new Wallet(Keypair.generate()); + const provider = new AnchorProvider( + new Connection(clusterApiUrl("devnet")), + wallet, + {} + ); + const program = new Program(VaultIDL as Vault, provider); + return program; +} + +export const vaultProgram = createVaultProgram(); + +export const getVaultBase = (allowedRebalance: boolean) => { + return allowedRebalance + ? new PublicKey("HWzXGcGHy4tcpYfaRDCyLNzXqBTv3E6BttpCH2vJxArv") + : PublicKey.default; +}; + +export const PUBLIC_KEY = 0; + +export const getVaultPdas = ( + tokenMint: PublicKey, + base: PublicKey, + vaultProgram: Program +) => { + const vaultPda = PublicKey.findProgramAddressSync( + [Buffer.from("vault"), tokenMint.toBuffer(), base.toBuffer()], + vaultProgram.programId + ); + + const tokenVaultPda = PublicKey.findProgramAddressSync( + [Buffer.from("token_vault"), vaultPda[PUBLIC_KEY].toBuffer()], + vaultProgram.programId + ); + + const lpMintPda = PublicKey.findProgramAddressSync( + [Buffer.from("lp_mint"), vaultPda[0].toBuffer()], + vaultProgram.programId + ); + + return { + vaultPda, + tokenVaultPda, + lpMintPda, + }; +}; + +export function getVaultAccount(svm: LiteSVM, vault: PublicKey) { + const vaultAccountBytes = svm.getAccount(vault); + if (vaultAccountBytes) + return vaultProgram.coder.accounts.decode( + "vault", + Buffer.from(vaultAccountBytes.data) + ) as IdlAccounts["vault"]; +} + +export async function setupVault( + svm: LiteSVM, + params: { + tokenMint: PublicKey; + adminKeypair: Keypair; + } +): Promise { + const { tokenMint, adminKeypair } = params; + + const vaultBase = getVaultBase(true); + + const admin = adminKeypair.publicKey; + + const { vaultPda, tokenVaultPda, lpMintPda } = await getVaultPdas( + tokenMint, + vaultBase, + vaultProgram + ); + + const account = getVaultAccount(svm, vaultPda[PUBLIC_KEY]); + + if (!account) { + const transaction = await vaultProgram.methods + .initialize() + .accountsPartial({ + vault: vaultPda[PUBLIC_KEY], + tokenVault: tokenVaultPda[PUBLIC_KEY], + tokenMint, + payer: admin, + lpMint: lpMintPda[PUBLIC_KEY], + rent: SYSVAR_RENT_PUBKEY, + systemProgram: SystemProgram.programId, + tokenProgram: TOKEN_PROGRAM_ID, + }) + .transaction(); + + sendTransaction(svm, transaction, [adminKeypair]); + } + + return vaultPda[PUBLIC_KEY]; +} + +export const depositVault = async ( + svm: LiteSVM, + depositVaultParams: { + vault: PublicKey; + userKeypair: Keypair; + depositAmount: BN; + } +) => { + const { vault, userKeypair, depositAmount } = depositVaultParams; + + const vaultAccount = getVaultAccount(svm, vault); + + const userWsolLpMint = await getOrCreateAtA( + svm, + userKeypair, + vaultAccount.lpMint, + userKeypair.publicKey, + TOKEN_PROGRAM_ID + ); + + const userToken = await getOrCreateAtA( + svm, + userKeypair, + vaultAccount.tokenMint, + userKeypair.publicKey, + TOKEN_PROGRAM_ID + ); + + const transaction = await vaultProgram.methods + .deposit(depositAmount, new BN(0)) + .accountsPartial({ + lpMint: vaultAccount.lpMint, + tokenProgram: TOKEN_PROGRAM_ID, + tokenVault: vaultAccount.tokenVault, + userLp: userWsolLpMint, + user: userKeypair.publicKey, + userToken, + vault, + }) + .transaction(); + + sendTransaction(svm, transaction, [userKeypair]); +}; diff --git a/tests/fixtures/damm_v1.so b/tests/fixtures/damm_v1.so new file mode 100755 index 0000000..ae86978 Binary files /dev/null and b/tests/fixtures/damm_v1.so differ diff --git a/tests/fixtures/mercurial_vault.so b/tests/fixtures/mercurial_vault.so new file mode 100755 index 0000000..820fb1e Binary files /dev/null and b/tests/fixtures/mercurial_vault.so differ diff --git a/tests/fixtures/metaplex.so b/tests/fixtures/metaplex.so new file mode 100644 index 0000000..fdc129a Binary files /dev/null and b/tests/fixtures/metaplex.so differ diff --git a/tests/test_zapout/zap_out_damm_v1.test.ts b/tests/test_zapout/zap_out_damm_v1.test.ts new file mode 100644 index 0000000..7bd0d37 --- /dev/null +++ b/tests/test_zapout/zap_out_damm_v1.test.ts @@ -0,0 +1,168 @@ +import { LiteSVM } from "litesvm"; +import { + PublicKey, + Keypair, + LAMPORTS_PER_SOL, + Transaction, +} from "@solana/web3.js"; +import { + createZapProgram, + createToken, + mintToken, + ZapProgram, + zapOutDammV1, + sendTransaction, + getTokenBalance, +} from "../common"; + +import ZapIDL from "../../target/idl/zap.json"; +import DAMMV1IDL from "../../idls/damm_v1.json"; +import MercurialVaultIDL from "../../idls/mercurial_vault.json"; +import { depositVault, setupVault } from "../common/vault"; +import BN from "bn.js"; +import { + addBalanceLiquidity, + removeLiquidity, + CurveType, + getAddLiquidityInputAmount, + METAPLEX_PROGRAM, + getDammV1Pool, + initializePermissionedPool, +} from "../common/damm_v1"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; +import { expect } from "chai"; + +describe("Zap out damm V1", () => { + let zapProgram: ZapProgram; + let svm: LiteSVM; + let user: Keypair; + let admin: Keypair; + let tokenAMint: PublicKey; + let tokenBMint: PublicKey; + + beforeEach(async () => { + zapProgram = createZapProgram(); + svm = new LiteSVM(); + svm.addProgramFromFile( + new PublicKey(ZapIDL.address), + "./target/deploy/zap.so" + ); + svm.addProgramFromFile( + new PublicKey(METAPLEX_PROGRAM), + "./tests/fixtures/metaplex.so" + ); + svm.addProgramFromFile( + new PublicKey(MercurialVaultIDL.address), + "./tests/fixtures/mercurial_vault.so" + ); + svm.addProgramFromFile( + new PublicKey(DAMMV1IDL.address), + "./tests/fixtures/damm_v1.so" + ); + + user = Keypair.generate(); + admin = Keypair.generate(); + svm.airdrop(user.publicKey, BigInt(100 * LAMPORTS_PER_SOL)); + svm.airdrop(admin.publicKey, BigInt(100 * LAMPORTS_PER_SOL)); + + tokenAMint = createToken(svm, admin, admin.publicKey, null); + tokenBMint = createToken(svm, admin, admin.publicKey, null); + mintToken(svm, admin, tokenAMint, admin, admin.publicKey); + mintToken(svm, admin, tokenBMint, admin, admin.publicKey); + + mintToken(svm, admin, tokenAMint, admin, user.publicKey); + mintToken(svm, admin, tokenBMint, admin, user.publicKey); + }); + + it("full flow zap out", async () => { + const inputTokenMint = tokenAMint; + + const aVault = await setupVault(svm, { + adminKeypair: admin, + tokenMint: tokenAMint, + }); + + const bVault = await setupVault(svm, { + adminKeypair: admin, + tokenMint: tokenBMint, + }); + + await depositVault(svm, { + vault: aVault, + depositAmount: new BN(1000), + userKeypair: admin, + }); + + await depositVault(svm, { + vault: bVault, + depositAmount: new BN(1000), + userKeypair: admin, + }); + + const poolKeypair = Keypair.generate(); + + const pool = await initializePermissionedPool(svm, { + aVault, + bVault, + aDepositAmount: new BN(1000), + bDepositAmount: new BN(1000), + adminKeypair: admin, + curve: CurveType.constantProduct(), + poolKeypair, + }); + + const poolAccount = getDammV1Pool(svm, pool); + + const { aDepositAmount, bDepositAmount, lpAmount } = + await getAddLiquidityInputAmount(svm, { + pool, + depositTokenMint: tokenAMint, + depositAmount: new BN(10000), + }); + + await addBalanceLiquidity(svm, { + pool, + lpAmount, + maxATokenAmount: aDepositAmount, + maxBTokenAmount: bDepositAmount, + userKeypair: user, + }); + + const userPoolLp = getAssociatedTokenAddressSync( + poolAccount.lpMint, + user.publicKey + ); + + const removeLiquidityTx = await removeLiquidity(svm, { + pool, + minAOutAmount: new BN(0), + minBOutAmount: new BN(0), + withdrawAmount: getTokenBalance(svm, userPoolLp), + userKeypair: user, + }); + + const zapOutTx = await zapOutDammV1( + svm, + user.publicKey, + inputTokenMint, + pool + ); + + const userTokenB = getAssociatedTokenAddressSync( + tokenBMint, + user.publicKey + ); + + const beforeUserTokenB = getTokenBalance(svm, userTokenB); + + const finalTransaction = new Transaction() + .add(removeLiquidityTx) + .add(zapOutTx); + + sendTransaction(svm, finalTransaction, [user]); + + const afterUserTokenB = getTokenBalance(svm, userTokenB); + + expect(afterUserTokenB.gt(beforeUserTokenB)).to.be.true; + }); +}); diff --git a/tests/test_zapout/zap_out_damm_v2.test.ts b/tests/test_zapout/zap_out_damm_v2.test.ts index a6155c2..51469af 100644 --- a/tests/test_zapout/zap_out_damm_v2.test.ts +++ b/tests/test_zapout/zap_out_damm_v2.test.ts @@ -14,7 +14,7 @@ import { createToken, mintToken, ZapProgram, - zapOutDammv2, + zapOutDammV2, } from "../common"; import { TOKEN_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token"; import { expect } from "chai"; @@ -88,7 +88,7 @@ describe("Zap out damm V2", () => { tokenBAccount ); - const zapOutTx = await zapOutDammv2( + const zapOutTx = await zapOutDammV2( svm, user.publicKey, inputTokenMint,