diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9dfbe1..0a53fa0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,8 +4,7 @@ on: pull_request: branches: - main - - release_0.2.0 - - zap_in + - release_0.2.1 env: SOLANA_CLI_VERSION: 2.1.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ac3a85..6ca4eb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Breaking Changes +## zap [0.2.1] [PR #41](https://github.com/MeteoraAg/zap-program/pull/41) + +### Fixed + +- Fix zap in damm-v2 with new base fee mode +- Add missing instructions sysvar in remaining accounts for `zap_in_damm_v2` which is used in rate limited DAMM v2 Pool for single swap validation + ## 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 7538b16..64060f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -729,8 +729,8 @@ checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "cp-amm" -version = "0.1.5" -source = "git+https://github.com/MeteoraAg/damm-v2?rev=689a3264484799d833c505523f4ff4e4990690aa#689a3264484799d833c505523f4ff4e4990690aa" +version = "0.1.6" +source = "git+https://github.com/MeteoraAg/damm-v2?rev=d9cef5aaec9cfa1a6d3b0b28d213c87c285127de#d9cef5aaec9cfa1a6d3b0b28d213c87c285127de" dependencies = [ "anchor-lang", "anchor-spl", @@ -739,6 +739,9 @@ dependencies = [ "num", "num-traits", "num_enum", + "pinocchio", + "pinocchio-token", + "pinocchio-token-2022", "ruint", "spl-token-metadata-interface", "static_assertions", @@ -1428,6 +1431,39 @@ dependencies = [ "ucd-trie", ] +[[package]] +name = "pinocchio" +version = "0.9.0" +source = "git+https://github.com/anza-xyz/pinocchio.git?rev=17b0e862c01a868ea07ef81a2f8a9b4a504bdfed#17b0e862c01a868ea07ef81a2f8a9b4a504bdfed" + +[[package]] +name = "pinocchio-pubkey" +version = "0.3.0" +source = "git+https://github.com/anza-xyz/pinocchio.git?rev=17b0e862c01a868ea07ef81a2f8a9b4a504bdfed#17b0e862c01a868ea07ef81a2f8a9b4a504bdfed" +dependencies = [ + "five8_const", + "pinocchio", + "sha2-const-stable", +] + +[[package]] +name = "pinocchio-token" +version = "0.4.0" +source = "git+https://github.com/anza-xyz/pinocchio.git?rev=17b0e862c01a868ea07ef81a2f8a9b4a504bdfed#17b0e862c01a868ea07ef81a2f8a9b4a504bdfed" +dependencies = [ + "pinocchio", + "pinocchio-pubkey", +] + +[[package]] +name = "pinocchio-token-2022" +version = "0.1.0" +source = "git+https://github.com/anza-xyz/pinocchio.git?rev=17b0e862c01a868ea07ef81a2f8a9b4a504bdfed#17b0e862c01a868ea07ef81a2f8a9b4a504bdfed" +dependencies = [ + "pinocchio", + "pinocchio-pubkey", +] + [[package]] name = "polyval" version = "0.6.2" @@ -3514,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_v2.json b/idls/damm_v2.json index a7bf2f7..6532516 100644 --- a/idls/damm_v2.json +++ b/idls/damm_v2.json @@ -2,30 +2,19 @@ "address": "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG", "metadata": { "name": "cp_amm", - "version": "0.1.5", + "version": "0.1.7", "spec": "0.1.0", "description": "Created with Anchor" }, "instructions": [ { "name": "add_liquidity", - "discriminator": [ - 181, - 157, - 89, - 67, - 143, - 182, - 52, - 72 - ], + "discriminator": [181, 157, 89, 67, 143, 182, 52, 72], "accounts": [ { "name": "pool", "writable": true, - "relations": [ - "position" - ] + "relations": ["position"] }, { "name": "position", @@ -33,80 +22,52 @@ }, { "name": "token_a_account", - "docs": [ - "The user token a account" - ], + "docs": ["The user token a account"], "writable": true }, { "name": "token_b_account", - "docs": [ - "The user token b account" - ], + "docs": ["The user token b account"], "writable": true }, { "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], + "docs": ["The vault token account for input token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], + "docs": ["The vault token account for output token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_a_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] + "docs": ["The mint of token a"], + "relations": ["pool"] }, { "name": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" - ] + "docs": ["The mint of token b"], + "relations": ["pool"] }, { "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] + "docs": ["The token account for nft"] }, { "name": "owner", - "docs": [ - "owner of position" - ], + "docs": ["owner of position"], "signer": true }, { "name": "token_a_program", - "docs": [ - "Token a program" - ] + "docs": ["Token a program"] }, { "name": "token_b_program", - "docs": [ - "Token b program" - ] + "docs": ["Token b program"] }, { "name": "event_authority", @@ -115,23 +76,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -154,16 +100,7 @@ }, { "name": "claim_partner_fee", - "discriminator": [ - 97, - 206, - 39, - 105, - 94, - 94, - 126, - 148 - ], + "discriminator": [97, 206, 39, 105, 94, 94, 126, 148], "accounts": [ { "name": "pool_authority", @@ -175,74 +112,48 @@ }, { "name": "token_a_account", - "docs": [ - "The treasury token a account" - ], + "docs": ["The treasury token a account"], "writable": true }, { "name": "token_b_account", - "docs": [ - "The treasury token b account" - ], + "docs": ["The treasury token b account"], "writable": true }, { "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], + "docs": ["The vault token account for input token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], + "docs": ["The vault token account for output token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_a_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] + "docs": ["The mint of token a"], + "relations": ["pool"] }, { "name": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" - ] + "docs": ["The mint of token b"], + "relations": ["pool"] }, { "name": "partner", "signer": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_a_program", - "docs": [ - "Token a program" - ] + "docs": ["Token a program"] }, { "name": "token_b_program", - "docs": [ - "Token b program" - ] + "docs": ["Token b program"] }, { "name": "event_authority", @@ -251,23 +162,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -290,16 +186,7 @@ }, { "name": "claim_position_fee", - "discriminator": [ - 180, - 38, - 154, - 17, - 133, - 33, - 162, - 211 - ], + "discriminator": [180, 38, 154, 17, 133, 33, 162, 211], "accounts": [ { "name": "pool_authority", @@ -307,9 +194,7 @@ }, { "name": "pool", - "relations": [ - "position" - ] + "relations": ["position"] }, { "name": "position", @@ -317,80 +202,52 @@ }, { "name": "token_a_account", - "docs": [ - "The user token a account" - ], + "docs": ["The user token a account"], "writable": true }, { "name": "token_b_account", - "docs": [ - "The user token b account" - ], + "docs": ["The user token b account"], "writable": true }, { "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], + "docs": ["The vault token account for input token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], + "docs": ["The vault token account for output token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_a_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] + "docs": ["The mint of token a"], + "relations": ["pool"] }, { "name": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" - ] + "docs": ["The mint of token b"], + "relations": ["pool"] }, { "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] + "docs": ["The token account for nft"] }, { "name": "owner", - "docs": [ - "owner of position" - ], + "docs": ["owner of position"], "signer": true }, { "name": "token_a_program", - "docs": [ - "Token a program" - ] + "docs": ["Token a program"] }, { "name": "token_b_program", - "docs": [ - "Token b program" - ] + "docs": ["Token b program"] }, { "name": "event_authority", @@ -399,23 +256,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -429,16 +271,7 @@ }, { "name": "claim_protocol_fee", - "discriminator": [ - 165, - 228, - 133, - 48, - 99, - 249, - 255, - 33 - ], + "discriminator": [165, 228, 133, 48, 99, 249, 255, 33], "accounts": [ { "name": "pool_authority", @@ -450,255 +283,50 @@ }, { "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], + "docs": ["The vault token account for input token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], + "docs": ["The vault token account for output token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_a_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] + "docs": ["The mint of token a"], + "relations": ["pool"] }, { "name": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" - ] + "docs": ["The mint of token b"], + "relations": ["pool"] }, { "name": "token_a_account", - "docs": [ - "The treasury token a account" - ], - "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": "account", - "path": "token_a_program" - }, - { - "kind": "account", - "path": "token_a_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 - ] - } - } + "writable": true }, { "name": "token_b_account", - "docs": [ - "The treasury token b account" - ], - "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": "account", - "path": "token_b_program" - }, - { - "kind": "account", - "path": "token_b_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 - ] - } - } + "writable": true }, { - "name": "claim_fee_operator", - "docs": [ - "Claim fee operator" - ] + "name": "operator", + "docs": ["Claim fee operator"] }, { - "name": "operator", - "docs": [ - "Operator" - ], - "signer": true, - "relations": [ - "claim_fee_operator" - ] + "name": "signer", + "docs": ["Operator"], + "signer": true }, { "name": "token_a_program", - "docs": [ - "Token a program" - ] + "docs": ["Token a program"] }, { "name": "token_b_program", - "docs": [ - "Token b program" - ] + "docs": ["Token b program"] }, { "name": "event_authority", @@ -707,23 +335,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -746,16 +359,7 @@ }, { "name": "claim_reward", - "discriminator": [ - 149, - 95, - 181, - 242, - 94, - 90, - 158, - 162 - ], + "discriminator": [149, 95, 181, 242, 94, 90, 158, 162], "accounts": [ { "name": "pool_authority", @@ -764,9 +368,7 @@ { "name": "pool", "writable": true, - "relations": [ - "position" - ] + "relations": ["position"] }, { "name": "position", @@ -774,9 +376,7 @@ }, { "name": "reward_vault", - "docs": [ - "The vault token account for reward token" - ], + "docs": ["The vault token account for reward token"], "writable": true }, { @@ -788,15 +388,11 @@ }, { "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] + "docs": ["The token account for nft"] }, { "name": "owner", - "docs": [ - "owner of position" - ], + "docs": ["owner of position"], "signer": true }, { @@ -809,23 +405,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -847,30 +428,24 @@ ] }, { - "name": "close_claim_fee_operator", - "discriminator": [ - 38, - 134, - 82, - 216, - 95, - 124, - 17, - 99 - ], + "name": "close_config", + "discriminator": [145, 9, 72, 157, 95, 125, 61, 85], "accounts": [ { - "name": "claim_fee_operator", + "name": "config", "writable": true }, { - "name": "rent_receiver", - "writable": true + "name": "operator" }, { - "name": "admin", + "name": "signer", "signer": true }, + { + "name": "rent_receiver", + "writable": true + }, { "name": "event_authority", "pda": { @@ -878,23 +453,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -907,25 +467,15 @@ "args": [] }, { - "name": "close_config", - "discriminator": [ - 145, - 9, - 72, - 157, - 95, - 125, - 61, - 85 - ], + "name": "close_operator_account", + "discriminator": [171, 9, 213, 74, 120, 23, 3, 29], "accounts": [ { - "name": "config", + "name": "operator", "writable": true }, { - "name": "admin", - "writable": true, + "name": "signer", "signer": true }, { @@ -939,23 +489,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -969,37 +504,22 @@ }, { "name": "close_position", - "discriminator": [ - 123, - 134, - 81, - 0, - 49, - 68, - 98, - 98 - ], + "discriminator": [123, 134, 81, 0, 49, 68, 98, 98], "accounts": [ { "name": "position_nft_mint", - "docs": [ - "position_nft_mint" - ], + "docs": ["position_nft_mint"], "writable": true }, { "name": "position_nft_account", - "docs": [ - "The token account for nft" - ], + "docs": ["The token account for nft"], "writable": true }, { "name": "pool", "writable": true, - "relations": [ - "position" - ] + "relations": ["position"] }, { "name": "position", @@ -1015,9 +535,7 @@ }, { "name": "owner", - "docs": [ - "Owner of position" - ], + "docs": ["Owner of position"], "signer": true }, { @@ -1034,23 +552,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -1064,24 +567,17 @@ }, { "name": "close_token_badge", - "discriminator": [ - 108, - 146, - 86, - 110, - 179, - 254, - 10, - 104 - ], + "discriminator": [108, 146, 86, 110, 179, 254, 10, 104], "accounts": [ { "name": "token_badge", "writable": true }, { - "name": "admin", - "writable": true, + "name": "operator" + }, + { + "name": "signer", "signer": true }, { @@ -1095,23 +591,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -1124,42 +605,22 @@ "args": [] }, { - "name": "create_claim_fee_operator", - "discriminator": [ - 169, - 62, - 207, - 107, - 58, - 187, - 162, - 109 - ], + "name": "create_config", + "docs": ["OPERATOR FUNCTIONS /////"], + "discriminator": [201, 207, 243, 114, 75, 111, 47, 189], "accounts": [ { - "name": "claim_fee_operator", + "name": "config", "writable": true, "pda": { "seeds": [ { "kind": "const", - "value": [ - 99, - 102, - 95, - 111, - 112, - 101, - 114, - 97, - 116, - 111, - 114 - ] + "value": [99, 111, 110, 102, 105, 103] }, { - "kind": "account", - "path": "operator" + "kind": "arg", + "path": "index" } ] } @@ -1168,7 +629,11 @@ "name": "operator" }, { - "name": "admin", + "name": "signer", + "signer": true + }, + { + "name": "payer", "writable": true, "signer": true }, @@ -1183,23 +648,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -1209,23 +659,24 @@ "name": "program" } ], - "args": [] + "args": [ + { + "name": "index", + "type": "u64" + }, + { + "name": "config_parameters", + "type": { + "defined": { + "name": "StaticConfigParameters" + } + } + } + ] }, { - "name": "create_config", - "docs": [ - "ADMIN FUNCTIONS /////" - ], - "discriminator": [ - 201, - 207, - 243, - 114, - 75, - 111, - 47, - 189 - ], + "name": "create_dynamic_config", + "discriminator": [81, 251, 122, 78, 66, 57, 208, 82], "accounts": [ { "name": "config", @@ -1234,14 +685,7 @@ "seeds": [ { "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] + "value": [99, 111, 110, 102, 105, 103] }, { "kind": "arg", @@ -1251,7 +695,14 @@ } }, { - "name": "admin", + "name": "operator" + }, + { + "name": "signer", + "signer": true + }, + { + "name": "payer", "writable": true, "signer": true }, @@ -1266,23 +717,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -1301,50 +737,42 @@ "name": "config_parameters", "type": { "defined": { - "name": "StaticConfigParameters" + "name": "DynamicConfigParameters" } } } ] }, { - "name": "create_dynamic_config", - "discriminator": [ - 81, - 251, - 122, - 78, - 66, - 57, - 208, - 82 - ], + "name": "create_operator_account", + "docs": ["ADMIN FUNCTIONS /////"], + "discriminator": [221, 64, 246, 149, 240, 153, 229, 163], "accounts": [ { - "name": "config", + "name": "operator", "writable": true, "pda": { "seeds": [ { "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] + "value": [111, 112, 101, 114, 97, 116, 111, 114] }, { - "kind": "arg", - "path": "index" + "kind": "account", + "path": "whitelisted_address" } ] } }, { - "name": "admin", + "name": "whitelisted_address" + }, + { + "name": "signer", + "signer": true + }, + { + "name": "payer", "writable": true, "signer": true }, @@ -1359,23 +787,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -1387,74 +800,35 @@ ], "args": [ { - "name": "index", - "type": "u64" - }, - { - "name": "config_parameters", - "type": { - "defined": { - "name": "DynamicConfigParameters" - } - } + "name": "permission", + "type": "u128" } ] }, { "name": "create_position", - "discriminator": [ - 48, - 215, - 197, - 153, - 96, - 203, - 180, - 133 - ], + "discriminator": [48, 215, 197, 153, 96, 203, 180, 133], "accounts": [ { "name": "owner" }, { "name": "position_nft_mint", - "docs": [ - "position_nft_mint" - ], + "docs": ["position_nft_mint"], "writable": true, "signer": true }, { "name": "position_nft_account", - "docs": [ - "position nft account" - ], + "docs": ["position nft account"], "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110, - 95, - 110, - 102, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 + 112, 111, 115, 105, 116, 105, 111, 110, 95, 110, 102, 116, 95, + 97, 99, 99, 111, 117, 110, 116 ] }, { @@ -1475,16 +849,7 @@ "seeds": [ { "kind": "const", - "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110 - ] + "value": [112, 111, 115, 105, 116, 105, 111, 110] }, { "kind": "account", @@ -1499,9 +864,7 @@ }, { "name": "payer", - "docs": [ - "Address paying to create the position. Can be anyone" - ], + "docs": ["Address paying to create the position. Can be anyone"], "writable": true, "signer": true }, @@ -1523,23 +886,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -1553,16 +901,7 @@ }, { "name": "create_token_badge", - "discriminator": [ - 88, - 206, - 0, - 91, - 60, - 175, - 151, - 118 - ], + "discriminator": [88, 206, 0, 91, 60, 175, 151, 118], "accounts": [ { "name": "token_badge", @@ -1571,19 +910,7 @@ "seeds": [ { "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 98, - 97, - 100, - 103, - 101 - ] + "value": [116, 111, 107, 101, 110, 95, 98, 97, 100, 103, 101] }, { "kind": "account", @@ -1596,7 +923,14 @@ "name": "token_mint" }, { - "name": "admin", + "name": "operator" + }, + { + "name": "signer", + "signer": true + }, + { + "name": "payer", "writable": true, "signer": true }, @@ -1611,23 +945,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -1640,33 +959,49 @@ "args": [] }, { - "name": "fund_reward", - "discriminator": [ - 188, - 50, - 249, - 165, - 93, - 151, - 38, - 63 - ], + "name": "dummy_ix", + "discriminator": [234, 95, 176, 185, 7, 42, 35, 159], "accounts": [ { - "name": "pool", - "writable": true + "name": "pod_aligned_fee_time_scheduler" }, { - "name": "reward_vault", - "writable": true + "name": "pod_aligned_fee_rate_limiter" }, { - "name": "reward_mint" - }, + "name": "pod_aligned_fee_market_cap_scheduler" + } + ], + "args": [ { - "name": "funder_token_account", - "writable": true - }, + "name": "_ixs", + "type": { + "defined": { + "name": "DummyParams" + } + } + } + ] + }, + { + "name": "fund_reward", + "discriminator": [188, 50, 249, 165, 93, 151, 38, 63], + "accounts": [ + { + "name": "pool", + "writable": true + }, + { + "name": "reward_vault", + "writable": true + }, + { + "name": "reward_mint" + }, + { + "name": "funder_token_account", + "writable": true + }, { "name": "funder", "signer": true @@ -1681,23 +1016,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -1724,59 +1044,28 @@ }, { "name": "initialize_customizable_pool", - "discriminator": [ - 20, - 161, - 241, - 24, - 189, - 221, - 180, - 2 - ], + "discriminator": [20, 161, 241, 24, 189, 221, 180, 2], "accounts": [ { "name": "creator" }, { "name": "position_nft_mint", - "docs": [ - "position_nft_mint" - ], + "docs": ["position_nft_mint"], "writable": true, "signer": true }, { "name": "position_nft_account", - "docs": [ - "position nft account" - ], + "docs": ["position nft account"], "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110, - 95, - 110, - 102, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 + 112, 111, 115, 105, 116, 105, 111, 110, 95, 110, 102, 116, 95, + 97, 99, 99, 111, 117, 110, 116 ] }, { @@ -1788,9 +1077,7 @@ }, { "name": "payer", - "docs": [ - "Address paying to create the pool. Can be anyone" - ], + "docs": ["Address paying to create the pool. Can be anyone"], "writable": true, "signer": true }, @@ -1800,9 +1087,7 @@ }, { "name": "pool", - "docs": [ - "Initialize an account to store the pool state" - ], + "docs": ["Initialize an account to store the pool state"], "writable": true }, { @@ -1812,16 +1097,7 @@ "seeds": [ { "kind": "const", - "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110 - ] + "value": [112, 111, 115, 105, 116, 105, 111, 110] }, { "kind": "account", @@ -1832,39 +1108,21 @@ }, { "name": "token_a_mint", - "docs": [ - "Token a mint" - ] + "docs": ["Token a mint"] }, { "name": "token_b_mint", - "docs": [ - "Token b mint" - ] + "docs": ["Token b mint"] }, { "name": "token_a_vault", - "docs": [ - "Token a vault for the pool" - ], + "docs": ["Token a vault for the pool"], "writable": true, "pda": { "seeds": [ { "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] + "value": [116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116] }, { "kind": "account", @@ -1879,27 +1137,13 @@ }, { "name": "token_b_vault", - "docs": [ - "Token b vault for the pool" - ], + "docs": ["Token b vault for the pool"], "writable": true, "pda": { "seeds": [ { "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] + "value": [116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116] }, { "kind": "account", @@ -1914,29 +1158,21 @@ }, { "name": "payer_token_a", - "docs": [ - "payer token a account" - ], + "docs": ["payer token a account"], "writable": true }, { "name": "payer_token_b", - "docs": [ - "creator token b account" - ], + "docs": ["creator token b account"], "writable": true }, { "name": "token_a_program", - "docs": [ - "Program to create mint account and mint tokens" - ] + "docs": ["Program to create mint account and mint tokens"] }, { "name": "token_b_program", - "docs": [ - "Program to create mint account and mint tokens" - ] + "docs": ["Program to create mint account and mint tokens"] }, { "name": "token_2022_program", @@ -1956,23 +1192,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -1995,62 +1216,29 @@ }, { "name": "initialize_pool", - "docs": [ - "USER FUNCTIONS ////" - ], - "discriminator": [ - 95, - 180, - 10, - 172, - 84, - 174, - 232, - 40 - ], + "docs": ["USER FUNCTIONS ////"], + "discriminator": [95, 180, 10, 172, 84, 174, 232, 40], "accounts": [ { "name": "creator" }, { "name": "position_nft_mint", - "docs": [ - "position_nft_mint" - ], + "docs": ["position_nft_mint"], "writable": true, "signer": true }, { "name": "position_nft_account", - "docs": [ - "position nft account" - ], + "docs": ["position nft account"], "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110, - 95, - 110, - 102, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 + 112, 111, 115, 105, 116, 105, 111, 110, 95, 110, 102, 116, 95, + 97, 99, 99, 111, 117, 110, 116 ] }, { @@ -2062,17 +1250,13 @@ }, { "name": "payer", - "docs": [ - "Address paying to create the pool. Can be anyone" - ], + "docs": ["Address paying to create the pool. Can be anyone"], "writable": true, "signer": true }, { "name": "config", - "docs": [ - "Which config the pool belongs to." - ] + "docs": ["Which config the pool belongs to."] }, { "name": "pool_authority", @@ -2080,9 +1264,7 @@ }, { "name": "pool", - "docs": [ - "Initialize an account to store the pool state" - ], + "docs": ["Initialize an account to store the pool state"], "writable": true }, { @@ -2092,16 +1274,7 @@ "seeds": [ { "kind": "const", - "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110 - ] + "value": [112, 111, 115, 105, 116, 105, 111, 110] }, { "kind": "account", @@ -2112,39 +1285,21 @@ }, { "name": "token_a_mint", - "docs": [ - "Token a mint" - ] + "docs": ["Token a mint"] }, { "name": "token_b_mint", - "docs": [ - "Token b mint" - ] + "docs": ["Token b mint"] }, { "name": "token_a_vault", - "docs": [ - "Token a vault for the pool" - ], + "docs": ["Token a vault for the pool"], "writable": true, "pda": { "seeds": [ { "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] + "value": [116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116] }, { "kind": "account", @@ -2159,27 +1314,13 @@ }, { "name": "token_b_vault", - "docs": [ - "Token b vault for the pool" - ], + "docs": ["Token b vault for the pool"], "writable": true, "pda": { "seeds": [ { "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] + "value": [116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116] }, { "kind": "account", @@ -2194,29 +1335,21 @@ }, { "name": "payer_token_a", - "docs": [ - "payer token a account" - ], + "docs": ["payer token a account"], "writable": true }, { "name": "payer_token_b", - "docs": [ - "creator token b account" - ], + "docs": ["creator token b account"], "writable": true }, { "name": "token_a_program", - "docs": [ - "Program to create mint account and mint tokens" - ] + "docs": ["Program to create mint account and mint tokens"] }, { "name": "token_b_program", - "docs": [ - "Program to create mint account and mint tokens" - ] + "docs": ["Program to create mint account and mint tokens"] }, { "name": "token_2022_program", @@ -2236,23 +1369,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -2275,59 +1393,28 @@ }, { "name": "initialize_pool_with_dynamic_config", - "discriminator": [ - 149, - 82, - 72, - 197, - 253, - 252, - 68, - 15 - ], + "discriminator": [149, 82, 72, 197, 253, 252, 68, 15], "accounts": [ { "name": "creator" }, { "name": "position_nft_mint", - "docs": [ - "position_nft_mint" - ], + "docs": ["position_nft_mint"], "writable": true, "signer": true }, { "name": "position_nft_account", - "docs": [ - "position nft account" - ], + "docs": ["position nft account"], "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110, - 95, - 110, - 102, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 + 112, 111, 115, 105, 116, 105, 111, 110, 95, 110, 102, 116, 95, + 97, 99, 99, 111, 117, 110, 116 ] }, { @@ -2339,24 +1426,18 @@ }, { "name": "payer", - "docs": [ - "Address paying to create the pool. Can be anyone" - ], + "docs": ["Address paying to create the pool. Can be anyone"], "writable": true, "signer": true }, { "name": "pool_creator_authority", "signer": true, - "relations": [ - "config" - ] + "relations": ["config"] }, { "name": "config", - "docs": [ - "Which config the pool belongs to." - ] + "docs": ["Which config the pool belongs to."] }, { "name": "pool_authority", @@ -2364,9 +1445,7 @@ }, { "name": "pool", - "docs": [ - "Initialize an account to store the pool state" - ], + "docs": ["Initialize an account to store the pool state"], "writable": true }, { @@ -2376,16 +1455,7 @@ "seeds": [ { "kind": "const", - "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110 - ] + "value": [112, 111, 115, 105, 116, 105, 111, 110] }, { "kind": "account", @@ -2396,39 +1466,21 @@ }, { "name": "token_a_mint", - "docs": [ - "Token a mint" - ] + "docs": ["Token a mint"] }, { "name": "token_b_mint", - "docs": [ - "Token b mint" - ] + "docs": ["Token b mint"] }, { "name": "token_a_vault", - "docs": [ - "Token a vault for the pool" - ], + "docs": ["Token a vault for the pool"], "writable": true, "pda": { "seeds": [ { "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] + "value": [116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116] }, { "kind": "account", @@ -2443,27 +1495,13 @@ }, { "name": "token_b_vault", - "docs": [ - "Token b vault for the pool" - ], + "docs": ["Token b vault for the pool"], "writable": true, "pda": { "seeds": [ { "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 118, - 97, - 117, - 108, - 116 - ] + "value": [116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116] }, { "kind": "account", @@ -2478,29 +1516,21 @@ }, { "name": "payer_token_a", - "docs": [ - "payer token a account" - ], + "docs": ["payer token a account"], "writable": true }, { "name": "payer_token_b", - "docs": [ - "creator token b account" - ], + "docs": ["creator token b account"], "writable": true }, { "name": "token_a_program", - "docs": [ - "Program to create mint account and mint tokens" - ] + "docs": ["Program to create mint account and mint tokens"] }, { "name": "token_b_program", - "docs": [ - "Program to create mint account and mint tokens" - ] + "docs": ["Program to create mint account and mint tokens"] }, { "name": "token_2022_program", @@ -2520,23 +1550,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -2559,16 +1574,7 @@ }, { "name": "initialize_reward", - "discriminator": [ - 95, - 135, - 192, - 196, - 242, - 129, - 230, - 68 - ], + "discriminator": [95, 135, 192, 196, 242, 129, 230, 68], "accounts": [ { "name": "pool_authority", @@ -2586,18 +1592,7 @@ { "kind": "const", "value": [ - 114, - 101, - 119, - 97, - 114, - 100, - 95, - 118, - 97, - 117, - 108, - 116 + 114, 101, 119, 97, 114, 100, 95, 118, 97, 117, 108, 116 ] }, { @@ -2637,23 +1632,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -2680,22 +1660,11 @@ }, { "name": "lock_position", - "discriminator": [ - 227, - 62, - 2, - 252, - 247, - 10, - 171, - 185 - ], + "discriminator": [227, 62, 2, 252, 247, 10, 171, 185], "accounts": [ { "name": "pool", - "relations": [ - "position" - ] + "relations": ["position"] }, { "name": "position", @@ -2708,15 +1677,11 @@ }, { "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] + "docs": ["The token account for nft"] }, { "name": "owner", - "docs": [ - "owner of position" - ], + "docs": ["owner of position"], "signer": true }, { @@ -2735,23 +1700,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -2774,23 +1724,12 @@ }, { "name": "permanent_lock_position", - "discriminator": [ - 165, - 176, - 125, - 6, - 231, - 171, - 186, - 213 - ], + "discriminator": [165, 176, 125, 6, 231, 171, 186, 213], "accounts": [ { "name": "pool", "writable": true, - "relations": [ - "position" - ] + "relations": ["position"] }, { "name": "position", @@ -2798,15 +1737,11 @@ }, { "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] + "docs": ["The token account for nft"] }, { "name": "owner", - "docs": [ - "owner of position" - ], + "docs": ["owner of position"], "signer": true }, { @@ -2816,23 +1751,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -2851,22 +1771,11 @@ }, { "name": "refresh_vesting", - "discriminator": [ - 9, - 94, - 216, - 14, - 116, - 204, - 247, - 0 - ], + "discriminator": [9, 94, 216, 14, 116, 204, 247, 0], "accounts": [ { "name": "pool", - "relations": [ - "position" - ] + "relations": ["position"] }, { "name": "position", @@ -2874,9 +1783,7 @@ }, { "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] + "docs": ["The token account for nft"] }, { "name": "owner" @@ -2886,16 +1793,7 @@ }, { "name": "remove_all_liquidity", - "discriminator": [ - 10, - 51, - 61, - 35, - 112, - 105, - 24, - 85 - ], + "discriminator": [10, 51, 61, 35, 112, 105, 24, 85], "accounts": [ { "name": "pool_authority", @@ -2904,9 +1802,7 @@ { "name": "pool", "writable": true, - "relations": [ - "position" - ] + "relations": ["position"] }, { "name": "position", @@ -2914,80 +1810,52 @@ }, { "name": "token_a_account", - "docs": [ - "The user token a account" - ], + "docs": ["The user token a account"], "writable": true }, { "name": "token_b_account", - "docs": [ - "The user token b account" - ], + "docs": ["The user token b account"], "writable": true }, { "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], + "docs": ["The vault token account for input token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], + "docs": ["The vault token account for output token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_a_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] + "docs": ["The mint of token a"], + "relations": ["pool"] }, { "name": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" - ] + "docs": ["The mint of token b"], + "relations": ["pool"] }, { "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] + "docs": ["The token account for nft"] }, { "name": "owner", - "docs": [ - "owner of position" - ], + "docs": ["owner of position"], "signer": true }, { "name": "token_a_program", - "docs": [ - "Token a program" - ] + "docs": ["Token a program"] }, { "name": "token_b_program", - "docs": [ - "Token b program" - ] + "docs": ["Token b program"] }, { "name": "event_authority", @@ -2996,23 +1864,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -3035,16 +1888,7 @@ }, { "name": "remove_liquidity", - "discriminator": [ - 80, - 85, - 209, - 72, - 24, - 206, - 177, - 108 - ], + "discriminator": [80, 85, 209, 72, 24, 206, 177, 108], "accounts": [ { "name": "pool_authority", @@ -3053,9 +1897,7 @@ { "name": "pool", "writable": true, - "relations": [ - "position" - ] + "relations": ["position"] }, { "name": "position", @@ -3063,80 +1905,52 @@ }, { "name": "token_a_account", - "docs": [ - "The user token a account" - ], + "docs": ["The user token a account"], "writable": true }, { "name": "token_b_account", - "docs": [ - "The user token b account" - ], + "docs": ["The user token b account"], "writable": true }, { "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], + "docs": ["The vault token account for input token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], + "docs": ["The vault token account for output token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_a_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] + "docs": ["The mint of token a"], + "relations": ["pool"] }, { "name": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" - ] + "docs": ["The mint of token b"], + "relations": ["pool"] }, { "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] + "docs": ["The token account for nft"] }, { "name": "owner", - "docs": [ - "owner of position" - ], + "docs": ["owner of position"], "signer": true }, { "name": "token_a_program", - "docs": [ - "Token a program" - ] + "docs": ["Token a program"] }, { "name": "token_b_program", - "docs": [ - "Token b program" - ] + "docs": ["Token b program"] }, { "name": "event_authority", @@ -3145,23 +1959,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -3184,23 +1983,17 @@ }, { "name": "set_pool_status", - "discriminator": [ - 112, - 87, - 135, - 223, - 83, - 204, - 132, - 53 - ], + "discriminator": [112, 87, 135, 223, 83, 204, 132, 53], "accounts": [ { "name": "pool", "writable": true }, { - "name": "admin", + "name": "operator" + }, + { + "name": "signer", "signer": true }, { @@ -3210,23 +2003,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -3245,63 +2023,39 @@ }, { "name": "split_position", - "discriminator": [ - 172, - 241, - 221, - 138, - 161, - 29, - 253, - 42 - ], + "discriminator": [172, 241, 221, 138, 161, 29, 253, 42], "accounts": [ { "name": "pool", "writable": true, - "relations": [ - "first_position", - "second_position" - ] + "relations": ["first_position", "second_position"] }, { "name": "first_position", - "docs": [ - "The first position" - ], + "docs": ["The first position"], "writable": true }, { "name": "first_position_nft_account", - "docs": [ - "The token account for position nft" - ] + "docs": ["The token account for position nft"] }, { "name": "second_position", - "docs": [ - "The second position" - ], + "docs": ["The second position"], "writable": true }, { "name": "second_position_nft_account", - "docs": [ - "The token account for position nft" - ] + "docs": ["The token account for position nft"] }, { "name": "first_owner", - "docs": [ - "Owner of first position" - ], + "docs": ["Owner of first position"], "signer": true }, { "name": "second_owner", - "docs": [ - "Owner of second position" - ], + "docs": ["Owner of second position"], "signer": true }, { @@ -3311,23 +2065,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -3350,63 +2089,39 @@ }, { "name": "split_position2", - "discriminator": [ - 221, - 147, - 228, - 207, - 140, - 212, - 17, - 119 - ], + "discriminator": [221, 147, 228, 207, 140, 212, 17, 119], "accounts": [ { "name": "pool", "writable": true, - "relations": [ - "first_position", - "second_position" - ] + "relations": ["first_position", "second_position"] }, { "name": "first_position", - "docs": [ - "The first position" - ], + "docs": ["The first position"], "writable": true }, { "name": "first_position_nft_account", - "docs": [ - "The token account for position nft" - ] + "docs": ["The token account for position nft"] }, { "name": "second_position", - "docs": [ - "The second position" - ], + "docs": ["The second position"], "writable": true }, { "name": "second_position_nft_account", - "docs": [ - "The token account for position nft" - ] + "docs": ["The token account for position nft"] }, { "name": "first_owner", - "docs": [ - "Owner of first position" - ], + "docs": ["Owner of first position"], "signer": true }, { "name": "second_owner", - "docs": [ - "Owner of second position" - ], + "docs": ["Owner of second position"], "signer": true }, { @@ -3416,23 +2131,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -3451,16 +2151,7 @@ }, { "name": "swap", - "discriminator": [ - 248, - 198, - 158, - 145, - 225, - 117, - 135, - 200 - ], + "discriminator": [248, 198, 158, 145, 225, 117, 135, 200], "accounts": [ { "name": "pool_authority", @@ -3468,81 +2159,55 @@ }, { "name": "pool", - "docs": [ - "Pool account" - ], + "docs": ["Pool account"], "writable": true }, { "name": "input_token_account", - "docs": [ - "The user token account for input token" - ], + "docs": ["The user token account for input token"], "writable": true }, { "name": "output_token_account", - "docs": [ - "The user token account for output token" - ], + "docs": ["The user token account for output token"], "writable": true }, { "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], + "docs": ["The vault token account for input token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], + "docs": ["The vault token account for output token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_a_mint", - "docs": [ - "The mint of token a" - ] + "docs": ["The mint of token a"] }, { "name": "token_b_mint", - "docs": [ - "The mint of token b" - ] + "docs": ["The mint of token b"] }, { "name": "payer", - "docs": [ - "The user performing the swap" - ], + "docs": ["The user performing the swap"], "signer": true }, { "name": "token_a_program", - "docs": [ - "Token a program" - ] + "docs": ["Token a program"] }, { "name": "token_b_program", - "docs": [ - "Token b program" - ] + "docs": ["Token b program"] }, { "name": "referral_token_account", - "docs": [ - "referral token account" - ], + "docs": ["referral token account"], "writable": true, "optional": true }, @@ -3553,23 +2218,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -3581,7 +2231,7 @@ ], "args": [ { - "name": "params", + "name": "_params", "type": { "defined": { "name": "SwapParameters" @@ -3592,16 +2242,7 @@ }, { "name": "swap2", - "discriminator": [ - 65, - 75, - 63, - 76, - 235, - 91, - 91, - 136 - ], + "discriminator": [65, 75, 63, 76, 235, 91, 91, 136], "accounts": [ { "name": "pool_authority", @@ -3609,81 +2250,55 @@ }, { "name": "pool", - "docs": [ - "Pool account" - ], + "docs": ["Pool account"], "writable": true }, { "name": "input_token_account", - "docs": [ - "The user token account for input token" - ], + "docs": ["The user token account for input token"], "writable": true }, { "name": "output_token_account", - "docs": [ - "The user token account for output token" - ], + "docs": ["The user token account for output token"], "writable": true }, { "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], + "docs": ["The vault token account for input token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], + "docs": ["The vault token account for output token"], "writable": true, - "relations": [ - "pool" - ] + "relations": ["pool"] }, { "name": "token_a_mint", - "docs": [ - "The mint of token a" - ] + "docs": ["The mint of token a"] }, { "name": "token_b_mint", - "docs": [ - "The mint of token b" - ] + "docs": ["The mint of token b"] }, { "name": "payer", - "docs": [ - "The user performing the swap" - ], + "docs": ["The user performing the swap"], "signer": true }, { "name": "token_a_program", - "docs": [ - "Token a program" - ] + "docs": ["Token a program"] }, { "name": "token_b_program", - "docs": [ - "Token b program" - ] + "docs": ["Token b program"] }, { "name": "referral_token_account", - "docs": [ - "referral token account" - ], + "docs": ["referral token account"], "writable": true, "optional": true }, @@ -3694,23 +2309,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -3722,7 +2322,7 @@ ], "args": [ { - "name": "params", + "name": "_params", "type": { "defined": { "name": "SwapParameters2" @@ -3732,22 +2332,16 @@ ] }, { - "name": "update_reward_duration", - "discriminator": [ - 138, - 174, - 196, - 169, - 213, - 235, - 254, - 107 - ], + "name": "update_pool_fees", + "discriminator": [118, 217, 203, 179, 60, 8, 70, 89], "accounts": [ { "name": "pool", "writable": true }, + { + "name": "operator" + }, { "name": "signer", "signer": true @@ -3759,23 +2353,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -3787,27 +2366,18 @@ ], "args": [ { - "name": "reward_index", - "type": "u8" - }, - { - "name": "new_duration", - "type": "u64" + "name": "params", + "type": { + "defined": { + "name": "UpdatePoolFeesParameters" + } + } } ] }, { - "name": "update_reward_funder", - "discriminator": [ - 211, - 28, - 48, - 32, - 215, - 160, - 35, - 23 - ], + "name": "update_reward_duration", + "discriminator": [138, 174, 196, 169, 213, 235, 254, 107], "accounts": [ { "name": "pool", @@ -3824,23 +2394,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -3856,35 +2411,67 @@ "type": "u8" }, { - "name": "new_funder", - "type": "pubkey" + "name": "new_duration", + "type": "u64" } ] }, { - "name": "withdraw_ineligible_reward", - "discriminator": [ - 148, - 206, - 42, - 195, - 247, - 49, - 103, - 8 - ], + "name": "update_reward_funder", + "discriminator": [211, 28, 48, 32, 215, 160, 35, 23], "accounts": [ - { - "name": "pool_authority", - "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" - }, { "name": "pool", "writable": true }, { - "name": "reward_vault", - "writable": true + "name": "signer", + "signer": 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": "reward_index", + "type": "u8" + }, + { + "name": "new_funder", + "type": "pubkey" + } + ] + }, + { + "name": "withdraw_ineligible_reward", + "discriminator": [148, 206, 42, 195, 247, 49, 103, 8], + "accounts": [ + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "pool", + "writable": true + }, + { + "name": "reward_vault", + "writable": true }, { "name": "reward_mint" @@ -3907,23 +2494,8 @@ { "kind": "const", "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, + 114, 105, 116, 121 ] } ] @@ -3939,439 +2511,186 @@ "type": "u8" } ] + }, + { + "name": "zap_protocol_fee", + "discriminator": [213, 155, 187, 34, 56, 182, 91, 240], + "accounts": [ + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "pool", + "writable": true + }, + { + "name": "token_vault", + "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"] + }, + { + "name": "sysvar_instructions", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "max_amount", + "type": "u64" + } + ] } ], "accounts": [ { - "name": "ClaimFeeOperator", - "discriminator": [ - 166, - 48, - 134, - 86, - 34, - 200, - 188, - 150 - ] + "name": "Config", + "discriminator": [155, 12, 170, 224, 30, 250, 204, 130] }, { - "name": "Config", - "discriminator": [ - 155, - 12, - 170, - 224, - 30, - 250, - 204, - 130 - ] + "name": "Operator", + "discriminator": [219, 31, 188, 145, 69, 139, 204, 117] + }, + { + "name": "PodAlignedFeeMarketCapScheduler", + "discriminator": [251, 130, 208, 253, 245, 27, 145, 203] + }, + { + "name": "PodAlignedFeeRateLimiter", + "discriminator": [160, 219, 8, 251, 179, 7, 16, 117] + }, + { + "name": "PodAlignedFeeTimeScheduler", + "discriminator": [239, 132, 138, 213, 67, 154, 130, 70] }, { "name": "Pool", - "discriminator": [ - 241, - 154, - 109, - 4, - 17, - 177, - 109, - 188 - ] + "discriminator": [241, 154, 109, 4, 17, 177, 109, 188] }, { "name": "Position", - "discriminator": [ - 170, - 188, - 143, - 228, - 122, - 64, - 247, - 208 - ] + "discriminator": [170, 188, 143, 228, 122, 64, 247, 208] }, { "name": "TokenBadge", - "discriminator": [ - 116, - 219, - 204, - 229, - 249, - 116, - 255, - 150 - ] + "discriminator": [116, 219, 204, 229, 249, 116, 255, 150] }, { "name": "Vesting", - "discriminator": [ - 100, - 149, - 66, - 138, - 95, - 200, - 128, - 241 - ] + "discriminator": [100, 149, 66, 138, 95, 200, 128, 241] } ], "events": [ - { - "name": "EvtAddLiquidity", - "discriminator": [ - 175, - 242, - 8, - 157, - 30, - 247, - 185, - 169 - ] - }, { "name": "EvtClaimPartnerFee", - "discriminator": [ - 118, - 99, - 77, - 10, - 226, - 1, - 1, - 87 - ] + "discriminator": [118, 99, 77, 10, 226, 1, 1, 87] }, { "name": "EvtClaimPositionFee", - "discriminator": [ - 198, - 182, - 183, - 52, - 97, - 12, - 49, - 56 - ] + "discriminator": [198, 182, 183, 52, 97, 12, 49, 56] }, { "name": "EvtClaimProtocolFee", - "discriminator": [ - 186, - 244, - 75, - 251, - 188, - 13, - 25, - 33 - ] + "discriminator": [186, 244, 75, 251, 188, 13, 25, 33] }, { "name": "EvtClaimReward", - "discriminator": [ - 218, - 86, - 147, - 200, - 235, - 188, - 215, - 231 - ] - }, - { - "name": "EvtCloseClaimFeeOperator", - "discriminator": [ - 111, - 39, - 37, - 55, - 110, - 216, - 194, - 23 - ] + "discriminator": [218, 86, 147, 200, 235, 188, 215, 231] }, { "name": "EvtCloseConfig", - "discriminator": [ - 36, - 30, - 239, - 45, - 58, - 132, - 14, - 5 - ] + "discriminator": [36, 30, 239, 45, 58, 132, 14, 5] }, { "name": "EvtClosePosition", - "discriminator": [ - 20, - 145, - 144, - 68, - 143, - 142, - 214, - 178 - ] - }, - { - "name": "EvtCreateClaimFeeOperator", - "discriminator": [ - 21, - 6, - 153, - 120, - 68, - 116, - 28, - 177 - ] + "discriminator": [20, 145, 144, 68, 143, 142, 214, 178] }, { "name": "EvtCreateConfig", - "discriminator": [ - 131, - 207, - 180, - 174, - 180, - 73, - 165, - 54 - ] + "discriminator": [131, 207, 180, 174, 180, 73, 165, 54] }, { "name": "EvtCreateDynamicConfig", - "discriminator": [ - 231, - 197, - 13, - 164, - 248, - 213, - 133, - 152 - ] + "discriminator": [231, 197, 13, 164, 248, 213, 133, 152] }, { "name": "EvtCreatePosition", - "discriminator": [ - 156, - 15, - 119, - 198, - 29, - 181, - 221, - 55 - ] + "discriminator": [156, 15, 119, 198, 29, 181, 221, 55] }, { "name": "EvtCreateTokenBadge", - "discriminator": [ - 141, - 120, - 134, - 116, - 34, - 28, - 114, - 160 - ] + "discriminator": [141, 120, 134, 116, 34, 28, 114, 160] }, { "name": "EvtFundReward", - "discriminator": [ - 104, - 233, - 237, - 122, - 199, - 191, - 121, - 85 - ] + "discriminator": [104, 233, 237, 122, 199, 191, 121, 85] }, { "name": "EvtInitializePool", - "discriminator": [ - 228, - 50, - 246, - 85, - 203, - 66, - 134, - 37 - ] + "discriminator": [228, 50, 246, 85, 203, 66, 134, 37] }, { "name": "EvtInitializeReward", - "discriminator": [ - 129, - 91, - 188, - 3, - 246, - 52, - 185, - 249 - ] + "discriminator": [129, 91, 188, 3, 246, 52, 185, 249] }, { "name": "EvtLiquidityChange", - "discriminator": [ - 197, - 171, - 78, - 127, - 224, - 211, - 87, - 13 - ] + "discriminator": [197, 171, 78, 127, 224, 211, 87, 13] }, { "name": "EvtLockPosition", - "discriminator": [ - 168, - 63, - 108, - 83, - 219, - 82, - 2, - 200 - ] + "discriminator": [168, 63, 108, 83, 219, 82, 2, 200] }, { "name": "EvtPermanentLockPosition", - "discriminator": [ - 145, - 143, - 162, - 218, - 218, - 80, - 67, - 11 - ] - }, - { - "name": "EvtRemoveLiquidity", - "discriminator": [ - 87, - 46, - 88, - 98, - 175, - 96, - 34, - 91 - ] + "discriminator": [145, 143, 162, 218, 218, 80, 67, 11] }, { "name": "EvtSetPoolStatus", - "discriminator": [ - 100, - 213, - 74, - 3, - 95, - 91, - 228, - 146 - ] + "discriminator": [100, 213, 74, 3, 95, 91, 228, 146] }, { "name": "EvtSplitPosition2", - "discriminator": [ - 165, - 32, - 203, - 174, - 72, - 100, - 233, - 103 - ] + "discriminator": [165, 32, 203, 174, 72, 100, 233, 103] }, { - "name": "EvtSwap", - "discriminator": [ - 27, - 60, - 21, - 213, - 138, - 170, - 187, - 147 - ] + "name": "EvtSwap2", + "discriminator": [189, 66, 51, 168, 38, 80, 117, 153] }, { - "name": "EvtSwap2", - "discriminator": [ - 189, - 66, - 51, - 168, - 38, - 80, - 117, - 153 - ] + "name": "EvtUpdatePoolFees", + "discriminator": [76, 165, 246, 102, 102, 217, 156, 44] }, { "name": "EvtUpdateRewardDuration", - "discriminator": [ - 149, - 135, - 65, - 231, - 129, - 153, - 65, - 57 - ] + "discriminator": [149, 135, 65, 231, 129, 153, 65, 57] }, { "name": "EvtUpdateRewardFunder", - "discriminator": [ - 76, - 154, - 208, - 13, - 40, - 115, - 246, - 146 - ] + "discriminator": [76, 154, 208, 13, 40, 115, 246, 146] }, { "name": "EvtWithdrawIneligibleReward", - "discriminator": [ - 248, - 215, - 184, - 78, - 31, - 180, - 179, - 168 - ] + "discriminator": [248, 215, 184, 78, 31, 180, 179, 168] } ], "errors": [ @@ -4627,7 +2946,7 @@ }, { "code": 6050, - "name": "InvalidFeeScheduler", + "name": "InvalidFeeTimeScheduler", "msg": "Invalid fee scheduler" }, { @@ -4639,6 +2958,76 @@ "code": 6052, "name": "InvalidPoolVersion", "msg": "Invalid pool version" + }, + { + "code": 6053, + "name": "InvalidAuthority", + "msg": "Invalid authority to do that action" + }, + { + "code": 6054, + "name": "InvalidPermission", + "msg": "Invalid permission" + }, + { + "code": 6055, + "name": "InvalidFeeMarketCapScheduler", + "msg": "Invalid fee market cap scheduler" + }, + { + "code": 6056, + "name": "CannotUpdateBaseFee", + "msg": "Cannot update base fee" + }, + { + "code": 6057, + "name": "InvalidDynamicFeeParameters", + "msg": "Invalid dynamic fee parameters" + }, + { + "code": 6058, + "name": "InvalidUpdatePoolFeesParameters", + "msg": "Invalid update pool fees parameters" + }, + { + "code": 6059, + "name": "MissingOperatorAccount", + "msg": "Missing operator account" + }, + { + "code": 6060, + "name": "IncorrectATA", + "msg": "Incorrect ATA" + }, + { + "code": 6061, + "name": "InvalidZapOutParameters", + "msg": "Invalid zap out parameters" + }, + { + "code": 6062, + "name": "InvalidWithdrawProtocolFeeZapAccounts", + "msg": "Invalid withdraw protocol fee zap accounts" + }, + { + "code": 6063, + "name": "MintRestrictedFromZap", + "msg": "SOL,USDC protocol fee cannot be withdrawn via zap" + }, + { + "code": 6064, + "name": "CpiDisabled", + "msg": "CPI disabled" + }, + { + "code": 6065, + "name": "MissingZapOutInstruction", + "msg": "Missing zap out instruction" + }, + { + "code": 6066, + "name": "InvalidZapAccounts", + "msg": "Invalid zap accounts" } ], "types": [ @@ -4649,30 +3038,24 @@ "fields": [ { "name": "liquidity_delta", - "docs": [ - "delta liquidity" - ], + "docs": ["delta liquidity"], "type": "u128" }, { "name": "token_a_amount_threshold", - "docs": [ - "maximum token a amount" - ], + "docs": ["maximum token a amount"], "type": "u64" }, { "name": "token_b_amount_threshold", - "docs": [ - "maximum token b amount" - ], + "docs": ["maximum token b amount"], "type": "u64" } ] } }, { - "name": "BaseFeeConfig", + "name": "BaseFeeInfo", "serialization": "bytemuck", "repr": { "kind": "c" @@ -4681,44 +3064,54 @@ "kind": "struct", "fields": [ { - "name": "cliff_fee_numerator", - "type": "u64" - }, - { - "name": "base_fee_mode", - "type": "u8" - }, - { - "name": "padding", + "name": "data", "type": { - "array": [ - "u8", - 5 - ] + "array": ["u8", 32] } - }, + } + ] + } + }, + { + "name": "BaseFeeParameters", + "type": { + "kind": "struct", + "fields": [ { - "name": "first_factor", - "type": "u16" - }, + "name": "data", + "type": { + "array": ["u8", 30] + } + } + ] + } + }, + { + "name": "BaseFeeStruct", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "second_factor", + "name": "base_fee_info", "type": { - "array": [ - "u8", - 8 - ] + "defined": { + "name": "BaseFeeInfo" + } } }, { - "name": "third_factor", + "name": "padding_1", "type": "u64" } ] } }, { - "name": "BaseFeeParameters", + "name": "BorshFeeMarketCapScheduler", "type": { "kind": "struct", "fields": [ @@ -4727,35 +3120,49 @@ "type": "u64" }, { - "name": "first_factor", + "name": "number_of_period", "type": "u16" }, { - "name": "second_factor", - "type": { - "array": [ - "u8", - 8 - ] - } + "name": "sqrt_price_step_bps", + "type": "u32" + }, + { + "name": "scheduler_expiration_duration", + "type": "u32" }, { - "name": "third_factor", + "name": "reduction_factor", "type": "u64" }, { "name": "base_fee_mode", "type": "u8" + }, + { + "name": "padding", + "type": { + "array": ["u8", 3] + } } ] } }, { - "name": "BaseFeeStruct", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, + "name": "BorshFeeRateLimiter", + "docs": [ + "we denote reference_amount = x0, cliff_fee_numerator = c, fee_increment = i", + "if input_amount <= x0, then fee = input_amount * c", + "", + "if input_amount > x0, then input_amount = x0 + (a * x0 + b)", + "if a < max_index", + "then fee = x0 * c + x0 * (c + i) + .... + x0 * (c + i*a) + b * (c + i * (a+1))", + "then fee = x0 * (c + c*a + i*a*(a+1)/2) + b * (c + i * (a+1))", + "", + "if a >= max_index", + "if a = max_index + d, input_amount = x0 + max_index * x0 + (d * x0 + b)", + "then fee = x0 * (c + c*max_index + i*max_index*(max_index+1)/2) + (d * x0 + b) * MAX_FEE" + ], "type": { "kind": "struct", "fields": [ @@ -4764,71 +3171,63 @@ "type": "u64" }, { - "name": "base_fee_mode", - "type": "u8" + "name": "fee_increment_bps", + "type": "u16" }, { - "name": "padding_0", - "type": { - "array": [ - "u8", - 5 - ] - } + "name": "max_limiter_duration", + "type": "u32" }, { - "name": "first_factor", - "type": "u16" + "name": "max_fee_bps", + "type": "u32" }, { - "name": "second_factor", - "type": { - "array": [ - "u8", - 8 - ] - } + "name": "reference_amount", + "type": "u64" }, { - "name": "third_factor", - "type": "u64" + "name": "base_fee_mode", + "type": "u8" }, { - "name": "padding_1", - "type": "u64" - } - ] + "name": "padding", + "type": { + "array": ["u8", 3] + } + } + ] } }, { - "name": "ClaimFeeOperator", - "docs": [ - "Parameter that set by the protocol" - ], - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, + "name": "BorshFeeTimeScheduler", "type": { "kind": "struct", "fields": [ { - "name": "operator", - "docs": [ - "operator" - ], - "type": "pubkey" + "name": "cliff_fee_numerator", + "type": "u64" }, { - "name": "_padding", - "docs": [ - "Reserve" - ], + "name": "number_of_period", + "type": "u16" + }, + { + "name": "period_frequency", + "type": "u64" + }, + { + "name": "reduction_factor", + "type": "u64" + }, + { + "name": "base_fee_mode", + "type": "u8" + }, + { + "name": "padding", "type": { - "array": [ - "u8", - 128 - ] + "array": ["u8", 3] } } ] @@ -4845,9 +3244,7 @@ "fields": [ { "name": "vault_config_key", - "docs": [ - "Vault config key" - ], + "docs": ["Vault config key"], "type": "pubkey" }, { @@ -4859,9 +3256,7 @@ }, { "name": "pool_fees", - "docs": [ - "Pool fee" - ], + "docs": ["Pool fee"], "type": { "defined": { "name": "PoolFeesConfig" @@ -4870,69 +3265,78 @@ }, { "name": "activation_type", - "docs": [ - "Activation type" - ], + "docs": ["Activation type"], "type": "u8" }, { "name": "collect_fee_mode", - "docs": [ - "Collect fee mode" - ], + "docs": ["Collect fee mode"], "type": "u8" }, { "name": "config_type", - "docs": [ - "Config type mode, 0 for static, 1 for dynamic" - ], + "docs": ["Config type mode, 0 for static, 1 for dynamic"], "type": "u8" }, { "name": "_padding_0", - "docs": [ - "padding 0" - ], + "docs": ["padding 0"], "type": { - "array": [ - "u8", - 5 - ] + "array": ["u8", 5] } }, { "name": "index", - "docs": [ - "config index" - ], + "docs": ["config index"], "type": "u64" }, { "name": "sqrt_min_price", - "docs": [ - "sqrt min price" - ], + "docs": ["sqrt min price"], "type": "u128" }, { "name": "sqrt_max_price", - "docs": [ - "sqrt max price" - ], + "docs": ["sqrt max price"], "type": "u128" }, { "name": "_padding_1", - "docs": [ - "Fee curve point", - "Padding for further use" - ], + "docs": ["Fee curve point", "Padding for further use"], "type": { - "array": [ - "u64", - 10 - ] + "array": ["u64", 10] + } + } + ] + } + }, + { + "name": "DummyParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "borsh_fee_time_scheduler_params", + "type": { + "defined": { + "name": "BorshFeeTimeScheduler" + } + } + }, + { + "name": "borsh_fee_rate_limiter_params", + "type": { + "defined": { + "name": "BorshFeeRateLimiter" + } + } + }, + { + "name": "borsh_fee_market_cap_scheduler_params", + "type": { + "defined": { + "name": "BorshFeeMarketCapScheduler" + } } } ] @@ -4966,10 +3370,7 @@ { "name": "padding", "type": { - "array": [ - "u8", - 7 - ] + "array": ["u8", 7] } }, { @@ -4999,10 +3400,7 @@ { "name": "padding_1", "type": { - "array": [ - "u8", - 8 - ] + "array": ["u8", 8] } }, { @@ -5064,10 +3462,7 @@ { "name": "padding", "type": { - "array": [ - "u8", - 7 - ] + "array": ["u8", 7] } }, { @@ -5117,50 +3512,6 @@ ] } }, - { - "name": "EvtAddLiquidity", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "params", - "type": { - "defined": { - "name": "AddLiquidityParameters" - } - } - }, - { - "name": "token_a_amount", - "type": "u64" - }, - { - "name": "token_b_amount", - "type": "u64" - }, - { - "name": "total_amount_a", - "type": "u64" - }, - { - "name": "total_amount_b", - "type": "u64" - } - ] - } - }, { "name": "EvtClaimPartnerFee", "type": { @@ -5261,45 +3612,20 @@ ] } }, - { - "name": "EvtCloseClaimFeeOperator", - "docs": [ - "Close claim fee operator" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "claim_fee_operator", - "type": "pubkey" - }, - { - "name": "operator", - "type": "pubkey" - } - ] - } - }, { "name": "EvtCloseConfig", - "docs": [ - "Close config" - ], + "docs": ["Close config"], "type": { "kind": "struct", "fields": [ { "name": "config", - "docs": [ - "Config pubkey" - ], + "docs": ["Config pubkey"], "type": "pubkey" }, { "name": "admin", - "docs": [ - "admin pk" - ], + "docs": ["admin pk"], "type": "pubkey" } ] @@ -5329,26 +3655,9 @@ ] } }, - { - "name": "EvtCreateClaimFeeOperator", - "docs": [ - "Create claim fee operator" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "operator", - "type": "pubkey" - } - ] - } - }, { "name": "EvtCreateConfig", - "docs": [ - "Create static config" - ], + "docs": ["Create static config"], "type": { "kind": "struct", "fields": [ @@ -5397,9 +3706,7 @@ }, { "name": "EvtCreateDynamicConfig", - "docs": [ - "Create dynamic config" - ], + "docs": ["Create dynamic config"], "type": { "kind": "struct", "fields": [ @@ -5444,9 +3751,7 @@ }, { "name": "EvtCreateTokenBadge", - "docs": [ - "Create token badge" - ], + "docs": ["Create token badge"], "type": { "kind": "struct", "fields": [ @@ -5757,42 +4062,6 @@ ] } }, - { - "name": "EvtRemoveLiquidity", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "params", - "type": { - "defined": { - "name": "RemoveLiquidityParameters" - } - } - }, - { - "name": "token_a_amount", - "type": "u64" - }, - { - "name": "token_b_amount", - "type": "u64" - } - ] - } - }, { "name": "EvtSetPoolStatus", "type": { @@ -5873,50 +4142,6 @@ ] } }, - { - "name": "EvtSwap", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "trade_direction", - "type": "u8" - }, - { - "name": "has_referral", - "type": "bool" - }, - { - "name": "params", - "type": { - "defined": { - "name": "SwapParameters" - } - } - }, - { - "name": "swap_result", - "type": { - "defined": { - "name": "SwapResult" - } - } - }, - { - "name": "actual_amount_in", - "type": "u64" - }, - { - "name": "current_timestamp", - "type": "u64" - } - ] - } - }, { "name": "EvtSwap2", "type": { @@ -5981,6 +4206,30 @@ ] } }, + { + "name": "EvtUpdatePoolFees", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "operator", + "type": "pubkey" + }, + { + "name": "params", + "type": { + "defined": { + "name": "UpdatePoolFeesParameters" + } + } + } + ] + } + }, { "name": "EvtUpdateRewardDuration", "type": { @@ -6056,9 +4305,7 @@ "fields": [ { "name": "pool_fees", - "docs": [ - "pool fees" - ], + "docs": ["pool fees"], "type": { "defined": { "name": "PoolFeeParameters" @@ -6067,58 +4314,44 @@ }, { "name": "sqrt_min_price", - "docs": [ - "sqrt min price" - ], + "docs": ["sqrt min price"], "type": "u128" }, { "name": "sqrt_max_price", - "docs": [ - "sqrt max price" - ], + "docs": ["sqrt max price"], "type": "u128" }, { "name": "has_alpha_vault", - "docs": [ - "has alpha vault" - ], + "docs": ["has alpha vault"], "type": "bool" }, { "name": "liquidity", - "docs": [ - "initialize liquidity" - ], + "docs": ["initialize liquidity"], "type": "u128" }, { "name": "sqrt_price", "docs": [ - "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value" + "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value. Market cap fee scheduler minimum price will be derived from this value" ], "type": "u128" }, { "name": "activation_type", - "docs": [ - "activation type" - ], + "docs": ["activation type"], "type": "u8" }, { "name": "collect_fee_mode", - "docs": [ - "collect fee mode" - ], + "docs": ["collect fee mode"], "type": "u8" }, { "name": "activation_point", - "docs": [ - "activation point" - ], + "docs": ["activation point"], "type": { "option": "u64" } @@ -6133,9 +4366,7 @@ "fields": [ { "name": "liquidity", - "docs": [ - "initialize liquidity" - ], + "docs": ["initialize liquidity"], "type": "u128" }, { @@ -6147,9 +4378,7 @@ }, { "name": "activation_point", - "docs": [ - "activation point" - ], + "docs": ["activation point"], "type": { "option": "u64" } @@ -6157,6 +4386,154 @@ ] } }, + { + "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": "PodAlignedFeeMarketCapScheduler", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "cliff_fee_numerator", + "type": "u64" + }, + { + "name": "base_fee_mode", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": ["u8", 5] + } + }, + { + "name": "number_of_period", + "type": "u16" + }, + { + "name": "sqrt_price_step_bps", + "type": "u32" + }, + { + "name": "scheduler_expiration_duration", + "type": "u32" + }, + { + "name": "reduction_factor", + "type": "u64" + } + ] + } + }, + { + "name": "PodAlignedFeeRateLimiter", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "cliff_fee_numerator", + "type": "u64" + }, + { + "name": "base_fee_mode", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": ["u8", 5] + } + }, + { + "name": "fee_increment_bps", + "type": "u16" + }, + { + "name": "max_limiter_duration", + "type": "u32" + }, + { + "name": "max_fee_bps", + "type": "u32" + }, + { + "name": "reference_amount", + "type": "u64" + } + ] + } + }, + { + "name": "PodAlignedFeeTimeScheduler", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "cliff_fee_numerator", + "type": "u64" + }, + { + "name": "base_fee_mode", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": ["u8", 5] + } + }, + { + "name": "number_of_period", + "type": "u16" + }, + { + "name": "period_frequency", + "type": "u64" + }, + { + "name": "reduction_factor", + "type": "u64" + } + ] + } + }, { "name": "Pool", "serialization": "bytemuck", @@ -6168,9 +4545,7 @@ "fields": [ { "name": "pool_fees", - "docs": [ - "Pool fee" - ], + "docs": ["Pool fee"], "type": { "defined": { "name": "PoolFeesStruct" @@ -6179,30 +4554,22 @@ }, { "name": "token_a_mint", - "docs": [ - "token a mint" - ], + "docs": ["token a mint"], "type": "pubkey" }, { "name": "token_b_mint", - "docs": [ - "token b mint" - ], + "docs": ["token b mint"], "type": "pubkey" }, { "name": "token_a_vault", - "docs": [ - "token a vault" - ], + "docs": ["token a vault"], "type": "pubkey" }, { "name": "token_b_vault", - "docs": [ - "token b vault" - ], + "docs": ["token b vault"], "type": "pubkey" }, { @@ -6214,16 +4581,12 @@ }, { "name": "partner", - "docs": [ - "partner" - ], + "docs": ["partner"], "type": "pubkey" }, { "name": "liquidity", - "docs": [ - "liquidity share" - ], + "docs": ["liquidity share"], "type": "u128" }, { @@ -6235,100 +4598,74 @@ }, { "name": "protocol_a_fee", - "docs": [ - "protocol a fee" - ], + "docs": ["protocol a fee"], "type": "u64" }, { "name": "protocol_b_fee", - "docs": [ - "protocol b fee" - ], + "docs": ["protocol b fee"], "type": "u64" }, { "name": "partner_a_fee", - "docs": [ - "partner a fee" - ], + "docs": ["partner a fee"], "type": "u64" }, { "name": "partner_b_fee", - "docs": [ - "partner b fee" - ], + "docs": ["partner b fee"], "type": "u64" }, { "name": "sqrt_min_price", - "docs": [ - "min price" - ], + "docs": ["min price"], "type": "u128" }, { "name": "sqrt_max_price", - "docs": [ - "max price" - ], + "docs": ["max price"], "type": "u128" }, { "name": "sqrt_price", - "docs": [ - "current price" - ], + "docs": ["current price"], "type": "u128" }, { "name": "activation_point", - "docs": [ - "Activation point, can be slot or timestamp" - ], + "docs": ["Activation point, can be slot or timestamp"], "type": "u64" }, { "name": "activation_type", - "docs": [ - "Activation type, 0 means by slot, 1 means by timestamp" - ], + "docs": ["Activation type, 0 means by slot, 1 means by timestamp"], "type": "u8" }, { "name": "pool_status", - "docs": [ - "pool status, 0: enable, 1 disable" - ], + "docs": ["pool status, 0: enable, 1 disable"], "type": "u8" }, { "name": "token_a_flag", - "docs": [ - "token a flag" - ], + "docs": ["token a flag"], "type": "u8" }, { "name": "token_b_flag", - "docs": [ - "token b flag" - ], + "docs": ["token b flag"], "type": "u8" }, { "name": "collect_fee_mode", "docs": [ - "0 is collect fee in both token, 1 only collect fee in token a, 2 only collect fee in token b" + "0 is collect fee in both token, 1 only collect fee only in token b" ], "type": "u8" }, { "name": "pool_type", - "docs": [ - "pool type" - ], + "docs": ["pool type"], "type": "u8" }, { @@ -6340,33 +4677,21 @@ }, { "name": "_padding_0", - "docs": [ - "padding" - ], + "docs": ["padding"], "type": "u8" }, { "name": "fee_a_per_liquidity", - "docs": [ - "cumulative" - ], + "docs": ["cumulative"], "type": { - "array": [ - "u8", - 32 - ] + "array": ["u8", 32] } }, { "name": "fee_b_per_liquidity", - "docs": [ - "cumulative" - ], + "docs": ["cumulative"], "type": { - "array": [ - "u8", - 32 - ] + "array": ["u8", 32] } }, { @@ -6375,9 +4700,7 @@ }, { "name": "metrics", - "docs": [ - "metrics" - ], + "docs": ["metrics"], "type": { "defined": { "name": "PoolMetrics" @@ -6386,28 +4709,19 @@ }, { "name": "creator", - "docs": [ - "pool creator" - ], + "docs": ["pool creator"], "type": "pubkey" }, { "name": "_padding_1", - "docs": [ - "Padding for further use" - ], + "docs": ["Padding for further use"], "type": { - "array": [ - "u64", - 6 - ] + "array": ["u64", 6] } }, { "name": "reward_infos", - "docs": [ - "Farming reward information" - ], + "docs": ["Farming reward information"], "type": { "array": [ { @@ -6424,40 +4738,22 @@ }, { "name": "PoolFeeParameters", - "docs": [ - "Information regarding fee charges" - ], + "docs": ["Information regarding fee charges"], "type": { "kind": "struct", "fields": [ { "name": "base_fee", - "docs": [ - "Base fee" - ], + "docs": ["Base fee"], "type": { "defined": { "name": "BaseFeeParameters" } } }, - { - "name": "padding", - "docs": [ - "padding" - ], - "type": { - "array": [ - "u8", - 3 - ] - } - }, { "name": "dynamic_fee", - "docs": [ - "dynamic fee" - ], + "docs": ["dynamic fee"], "type": { "option": { "defined": { @@ -6482,7 +4778,7 @@ "name": "base_fee", "type": { "defined": { - "name": "BaseFeeConfig" + "name": "BaseFeeInfo" } } }, @@ -6509,19 +4805,13 @@ { "name": "padding_0", "type": { - "array": [ - "u8", - 5 - ] + "array": ["u8", 5] } }, { "name": "padding_1", "type": { - "array": [ - "u64", - 5 - ] + "array": ["u64", 5] } } ] @@ -6568,35 +4858,24 @@ }, { "name": "partner_fee_percent", - "docs": [ - "partner fee" - ], + "docs": ["partner fee"], "type": "u8" }, { "name": "referral_fee_percent", - "docs": [ - "referral fee" - ], + "docs": ["referral fee"], "type": "u8" }, { "name": "padding_0", - "docs": [ - "padding" - ], + "docs": ["padding"], "type": { - "array": [ - "u8", - 5 - ] + "array": ["u8", 5] } }, { "name": "dynamic_fee", - "docs": [ - "dynamic fee" - ], + "docs": ["dynamic fee"], "type": { "defined": { "name": "DynamicFeeStruct" @@ -6604,16 +4883,8 @@ } }, { - "name": "padding_1", - "docs": [ - "padding" - ], - "type": { - "array": [ - "u64", - 2 - ] - } + "name": "init_sqrt_price", + "type": "u128" } ] } @@ -6677,75 +4948,51 @@ }, { "name": "nft_mint", - "docs": [ - "nft mint" - ], + "docs": ["nft mint"], "type": "pubkey" }, { "name": "fee_a_per_token_checkpoint", - "docs": [ - "fee a checkpoint" - ], + "docs": ["fee a checkpoint"], "type": { - "array": [ - "u8", - 32 - ] + "array": ["u8", 32] } }, { "name": "fee_b_per_token_checkpoint", - "docs": [ - "fee b checkpoint" - ], + "docs": ["fee b checkpoint"], "type": { - "array": [ - "u8", - 32 - ] + "array": ["u8", 32] } }, { "name": "fee_a_pending", - "docs": [ - "fee a pending" - ], + "docs": ["fee a pending"], "type": "u64" }, { "name": "fee_b_pending", - "docs": [ - "fee b pending" - ], + "docs": ["fee b pending"], "type": "u64" }, { "name": "unlocked_liquidity", - "docs": [ - "unlock liquidity" - ], + "docs": ["unlock liquidity"], "type": "u128" }, { "name": "vested_liquidity", - "docs": [ - "vesting liquidity" - ], + "docs": ["vesting liquidity"], "type": "u128" }, { "name": "permanent_locked_liquidity", - "docs": [ - "permanent locked liquidity" - ], + "docs": ["permanent locked liquidity"], "type": "u128" }, { "name": "metrics", - "docs": [ - "metrics" - ], + "docs": ["metrics"], "type": { "defined": { "name": "PositionMetrics" @@ -6754,9 +5001,7 @@ }, { "name": "reward_infos", - "docs": [ - "Farming reward information" - ], + "docs": ["Farming reward information"], "type": { "array": [ { @@ -6770,14 +5015,9 @@ }, { "name": "padding", - "docs": [ - "padding for future usage" - ], + "docs": ["padding for future usage"], "type": { - "array": [ - "u128", - 6 - ] + "array": ["u128", 6] } } ] @@ -6810,23 +5050,17 @@ "fields": [ { "name": "liquidity_delta", - "docs": [ - "delta liquidity" - ], + "docs": ["delta liquidity"], "type": "u128" }, { "name": "token_a_amount_threshold", - "docs": [ - "minimum token a amount" - ], + "docs": ["minimum token a amount"], "type": "u64" }, { "name": "token_b_amount_threshold", - "docs": [ - "minimum token b amount" - ], + "docs": ["minimum token b amount"], "type": "u64" } ] @@ -6846,28 +5080,19 @@ "fields": [ { "name": "initialized", - "docs": [ - "Indicates if the reward has been initialized" - ], + "docs": ["Indicates if the reward has been initialized"], "type": "u8" }, { "name": "reward_token_flag", - "docs": [ - "reward token flag" - ], + "docs": ["reward token flag"], "type": "u8" }, { "name": "_padding_0", - "docs": [ - "padding" - ], + "docs": ["padding"], "type": { - "array": [ - "u8", - 6 - ] + "array": ["u8", 6] } }, { @@ -6876,71 +5101,49 @@ "Padding to ensure `reward_rate: u128` is 16-byte aligned" ], "type": { - "array": [ - "u8", - 8 - ] + "array": ["u8", 8] } }, { "name": "mint", - "docs": [ - "Reward token mint." - ], + "docs": ["Reward token mint."], "type": "pubkey" }, { "name": "vault", - "docs": [ - "Reward vault token account." - ], + "docs": ["Reward vault token account."], "type": "pubkey" }, { "name": "funder", - "docs": [ - "Authority account that allows to fund rewards" - ], + "docs": ["Authority account that allows to fund rewards"], "type": "pubkey" }, { "name": "reward_duration", - "docs": [ - "reward duration" - ], + "docs": ["reward duration"], "type": "u64" }, { "name": "reward_duration_end", - "docs": [ - "reward duration end" - ], + "docs": ["reward duration end"], "type": "u64" }, { "name": "reward_rate", - "docs": [ - "reward rate" - ], + "docs": ["reward rate"], "type": "u128" }, { "name": "reward_per_token_stored", - "docs": [ - "Reward per token stored" - ], + "docs": ["Reward per token stored"], "type": { - "array": [ - "u8", - 32 - ] + "array": ["u8", 32] } }, { "name": "last_update_time", - "docs": [ - "The last time reward states were updated." - ], + "docs": ["The last time reward states were updated."], "type": "u64" }, { @@ -7063,14 +5266,9 @@ }, { "name": "padding", - "docs": [ - "padding for future" - ], + "docs": ["padding for future"], "type": { - "array": [ - "u8", - 16 - ] + "array": ["u8", 16] } } ] @@ -7185,49 +5383,12 @@ }, { "name": "swap_mode", - "docs": [ - "Swap mode, refer [SwapMode]" - ], + "docs": ["Swap mode, refer [SwapMode]"], "type": "u8" } ] } }, - { - "name": "SwapResult", - "docs": [ - "Encodes all results of swapping" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "output_amount", - "type": "u64" - }, - { - "name": "next_sqrt_price", - "type": "u128" - }, - { - "name": "lp_fee", - "type": "u64" - }, - { - "name": "protocol_fee", - "type": "u64" - }, - { - "name": "partner_fee", - "type": "u64" - }, - { - "name": "referral_fee", - "type": "u64" - } - ] - } - }, { "name": "SwapResult2", "type": { @@ -7274,9 +5435,7 @@ }, { "name": "TokenBadge", - "docs": [ - "Parameter that set by the protocol" - ], + "docs": ["Parameter that set by the protocol"], "serialization": "bytemuck", "repr": { "kind": "c" @@ -7286,21 +5445,49 @@ "fields": [ { "name": "token_mint", - "docs": [ - "token mint" - ], + "docs": ["token mint"], "type": "pubkey" }, { "name": "_padding", + "docs": ["Reserve"], + "type": { + "array": ["u8", 128] + } + } + ] + } + }, + { + "name": "UpdatePoolFeesParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "cliff_fee_numerator", "docs": [ - "Reserve" + "Base fee update mode:", + "- None: skip base fee update", + "- Some: update new cliff_fee_numerator if base fee is static" ], "type": { - "array": [ - "u8", - 128 - ] + "option": "u64" + } + }, + { + "name": "dynamic_fee", + "docs": [ + "Dynamic fee update mode:", + "- None: skip dynamic fee update", + "- Some(with default value): disable dynamic fee", + "- Some(with non default value): enable dynamic fee if disabled or update dynamic fee if enabled" + ], + "type": { + "option": { + "defined": { + "name": "DynamicFeeParameters" + } + } } } ] @@ -7317,28 +5504,19 @@ "fields": [ { "name": "reward_per_token_checkpoint", - "docs": [ - "The latest update reward checkpoint" - ], + "docs": ["The latest update reward checkpoint"], "type": { - "array": [ - "u8", - 32 - ] + "array": ["u8", 32] } }, { "name": "reward_pendings", - "docs": [ - "Current pending rewards" - ], + "docs": ["Current pending rewards"], "type": "u64" }, { "name": "total_claimed_rewards", - "docs": [ - "Total claimed rewards" - ], + "docs": ["Total claimed rewards"], "type": "u64" } ] @@ -7384,19 +5562,13 @@ { "name": "padding", "type": { - "array": [ - "u8", - 14 - ] + "array": ["u8", 14] } }, { "name": "padding2", "type": { - "array": [ - "u128", - 4 - ] + "array": ["u128", 4] } } ] @@ -7432,5 +5604,82 @@ ] } } + ], + "constants": [ + { + "name": "BIN_STEP_BPS_DEFAULT", + "type": "u16", + "value": "1" + }, + { + "name": "BIN_STEP_U128_DEFAULT_LE_BYTES", + "type": { + "array": ["u8", 16] + }, + "value": "[203, 16, 199, 186, 184, 141, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0]" + }, + { + "name": "CUSTOMIZABLE_POOL_PREFIX", + "type": "bytes", + "value": "[99, 112, 111, 111, 108]" + }, + { + "name": "FEE_DENOMINATOR", + "docs": [ + "Default fee denominator. DO NOT simply update it as it will break logic that depends on it as default value." + ], + "type": "u64", + "value": "1000000000" + }, + { + "name": "MAX_BASIS_POINT", + "docs": ["Max basis point. 100% in pct"], + "type": "u64", + "value": "10000" + }, + { + "name": "MAX_SQRT_PRICE_LE_BYTES", + "type": { + "array": ["u8", 16] + }, + "value": "[155, 87, 105, 78, 169, 26, 92, 132, 177, 196, 254, 255, 0, 0, 0, 0]" + }, + { + "name": "MIN_SQRT_PRICE_LE_BYTES", + "type": { + "array": ["u8", 16] + }, + "value": "[80, 59, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]" + }, + { + "name": "POOL_AUTHORITY_PREFIX", + "type": "bytes", + "value": "[112, 111, 111, 108, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]" + }, + { + "name": "POOL_PREFIX", + "type": "bytes", + "value": "[112, 111, 111, 108]" + }, + { + "name": "POSITION_NFT_ACCOUNT_PREFIX", + "type": "bytes", + "value": "[112, 111, 115, 105, 116, 105, 111, 110, 95, 110, 102, 116, 95, 97, 99, 99, 111, 117, 110, 116]" + }, + { + "name": "POSITION_PREFIX", + "type": "bytes", + "value": "[112, 111, 115, 105, 116, 105, 111, 110]" + }, + { + "name": "SPLIT_POSITION_DENOMINATOR", + "type": "u32", + "value": "1000000000" + }, + { + "name": "TOKEN_VAULT_PREFIX", + "type": "bytes", + "value": "[116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116]" + } ] -} \ No newline at end of file +} diff --git a/programs/zap/Cargo.toml b/programs/zap/Cargo.toml index 580a97b..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,6 +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", - "no-entrypoint", -], rev = "689a3264484799d833c505523f4ff4e4990690aa", 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/instructions/ix_zap_in_damm_v2.rs b/programs/zap/src/instructions/ix_zap_in_damm_v2.rs index 06544f8..362970a 100644 --- a/programs/zap/src/instructions/ix_zap_in_damm_v2.rs +++ b/programs/zap/src/instructions/ix_zap_in_damm_v2.rs @@ -67,7 +67,12 @@ pub struct ZapInDammv2Ctx<'info> { } impl<'info> ZapInDammv2Ctx<'info> { - fn swap(&self, amount: u64, trade_direction: TradeDirection) -> Result<()> { + fn swap( + &self, + amount: u64, + trade_direction: TradeDirection, + remaining_accounts: &[AccountInfo<'info>], + ) -> Result<()> { let (input_token_account, output_token_account) = if trade_direction == TradeDirection::AtoB { ( @@ -99,7 +104,8 @@ impl<'info> ZapInDammv2Ctx<'info> { payer: self.owner.to_account_info(), referral_token_account: None, // TODO check whether it should be some(damm_program) }, - ), + ) + .with_remaining_accounts(remaining_accounts.to_vec()), SwapParameters2 { amount_0: amount, amount_1: 0, @@ -140,8 +146,8 @@ impl<'info> ZapInDammv2Ctx<'info> { } } -pub fn handle_zap_in_damm_v2( - ctx: Context, +pub fn handle_zap_in_damm_v2<'c: 'info, 'info>( + ctx: Context<'_, '_, 'c, 'info, ZapInDammv2Ctx<'info>>, pre_sqrt_price: u128, // sqrt price user observe in local max_sqrt_price_change_bps: u32, // max sqrt price change after swap ) -> Result<()> { @@ -216,7 +222,8 @@ pub fn handle_zap_in_damm_v2( return Ok(()); // no need to swap, just return } drop(pool); - ctx.accounts.swap(swap_in_amount, trade_direction)?; + ctx.accounts + .swap(swap_in_amount, trade_direction, &ctx.remaining_accounts)?; } Err(err) => { // if calculation fail, we just skip swap and add liquidity with remaining amount 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/programs/zap/src/instructions/zap_in_dlmm/ix_zap_in_dlmm_for_initialized_position.rs b/programs/zap/src/instructions/zap_in_dlmm/ix_zap_in_dlmm_for_initialized_position.rs index e9be5c6..a4e6fd1 100644 --- a/programs/zap/src/instructions/zap_in_dlmm/ix_zap_in_dlmm_for_initialized_position.rs +++ b/programs/zap/src/instructions/zap_in_dlmm/ix_zap_in_dlmm_for_initialized_position.rs @@ -86,12 +86,22 @@ pub fn handle_zap_in_dlmm_for_initialized_position<'c: 'info, 'info>( let pre_user_amount_x = accessor::amount(&token_x_account_ai)?; let pre_user_amount_y = accessor::amount(&token_y_account_ai)?; - let amount_x = - calculate_transfer_fee_excluded_amount(&ctx.accounts.token_x_mint, max_deposit_x_amount)? - .amount; - let amount_y = - calculate_transfer_fee_excluded_amount(&ctx.accounts.token_y_mint, max_deposit_y_amount)? - .amount; + let amount_x = calculate_transfer_fee_excluded_amount( + &ctx.accounts + .token_x_mint + .to_account_info() + .try_borrow_data()?, + max_deposit_x_amount, + )? + .amount; + let amount_y = calculate_transfer_fee_excluded_amount( + &ctx.accounts + .token_y_mint + .to_account_info() + .try_borrow_data()?, + max_deposit_y_amount, + )? + .amount; let lb_pair = ctx.accounts.lb_pair.load()?; diff --git a/programs/zap/src/instructions/zap_in_dlmm/ix_zap_in_dlmm_for_uninitialized_position.rs b/programs/zap/src/instructions/zap_in_dlmm/ix_zap_in_dlmm_for_uninitialized_position.rs index ce5593d..37af6d3 100644 --- a/programs/zap/src/instructions/zap_in_dlmm/ix_zap_in_dlmm_for_uninitialized_position.rs +++ b/programs/zap/src/instructions/zap_in_dlmm/ix_zap_in_dlmm_for_uninitialized_position.rs @@ -132,12 +132,22 @@ pub fn handle_zap_in_dlmm_for_uninitialized_position<'c: 'info, 'info>( let lb_pair = ctx.accounts.lb_pair.load()?; let lb_pair_active_id = lb_pair.active_id; - let amount_x = - calculate_transfer_fee_excluded_amount(&ctx.accounts.token_x_mint, max_deposit_x_amount)? - .amount; - let amount_y = - calculate_transfer_fee_excluded_amount(&ctx.accounts.token_y_mint, max_deposit_y_amount)? - .amount; + let amount_x = calculate_transfer_fee_excluded_amount( + &ctx.accounts + .token_x_mint + .to_account_info() + .try_borrow_data()?, + max_deposit_x_amount, + )? + .amount; + let amount_y = calculate_transfer_fee_excluded_amount( + &ctx.accounts + .token_y_mint + .to_account_info() + .try_borrow_data()?, + max_deposit_y_amount, + )? + .amount; let params = ZapInRebalancingParams { amount_x, diff --git a/programs/zap/src/lib.rs b/programs/zap/src/lib.rs index e998a23..74e8104 100644 --- a/programs/zap/src/lib.rs +++ b/programs/zap/src/lib.rs @@ -57,8 +57,8 @@ pub mod zap { ) } - pub fn zap_in_damm_v2( - ctx: Context, + pub fn zap_in_damm_v2<'c: 'info, 'info>( + ctx: Context<'_, '_, 'c, 'info, ZapInDammv2Ctx<'info>>, pre_sqrt_price: u128, max_sqrt_price_change_bps: u32, ) -> Result<()> { diff --git a/programs/zap/src/utils/damm_v2_utils.rs b/programs/zap/src/utils/damm_v2_utils.rs index 6db2e11..94820b9 100644 --- a/programs/zap/src/utils/damm_v2_utils.rs +++ b/programs/zap/src/utils/damm_v2_utils.rs @@ -1,6 +1,9 @@ use anchor_lang::prelude::*; use damm_v2::{ - base_fee::{BaseFeeHandler, FeeRateLimiter}, + base_fee::{ + fee_rate_limiter::PodAlignedFeeRateLimiter, BaseFeeEnumReader, BaseFeeHandler, + BaseFeeHandlerBuilder, + }, constants::fee::get_max_fee_numerator, curve::{ get_delta_amount_a_unsigned, get_delta_amount_b_unsigned, get_next_sqrt_price_from_input, @@ -142,6 +145,8 @@ fn calculate_swap_result( current_point, pool.activation_point, trade_direction, + pool.pool_fees.init_sqrt_price, + pool.sqrt_price, )?; let actual_amount_in = if fee_mode.fees_on_input { let FeeOnAmountResult { amount, .. } = pool.pool_fees.get_fee_on_amount( @@ -245,7 +250,7 @@ fn validate_swap_result( } struct FeeHandler { - pub rate_limiter_handler: FeeRateLimiter, // avoid copy + pub rate_limiter_handler: PodAlignedFeeRateLimiter, // avoid copy pub variable_fee_numerator: u128, pub max_fee_numerator: u64, pub total_fee_numerator: u64, @@ -259,6 +264,8 @@ impl FeeHandler { current_point: u64, activation_point: u64, trade_direction: TradeDirection, + init_sqrt_price: u128, + current_sqrt_price: u128, ) -> Result { if self.is_rate_limiter { let base_fee_numerator = self @@ -268,6 +275,8 @@ impl FeeHandler { activation_point, trade_direction, input_amount, + init_sqrt_price, + current_sqrt_price, )?; get_total_fee_numerator( @@ -289,12 +298,19 @@ fn get_fee_handler( let variable_fee_numerator = pool.pool_fees.dynamic_fee.get_variable_fee()?; let max_fee_numerator = get_max_fee_numerator(pool.version)?; - let base_fee_mode = pool.pool_fees.base_fee.base_fee_mode; + let base_fee_mode = pool.pool_fees.base_fee.base_fee_info.get_base_fee_mode()?; match BaseFeeMode::try_from(base_fee_mode) { Ok(value) => { match value { - BaseFeeMode::FeeSchedulerLinear | BaseFeeMode::FeeSchedulerExponential => { - let base_fee_handler = pool.pool_fees.base_fee.get_base_fee_handler()?; + BaseFeeMode::FeeTimeSchedulerLinear + | BaseFeeMode::FeeTimeSchedulerExponential + | BaseFeeMode::FeeMarketCapSchedulerLinear + | BaseFeeMode::FeeMarketCapSchedulerExponential => { + let base_fee_handler = pool + .pool_fees + .base_fee + .base_fee_info + .get_base_fee_handler()?; // fee scheduler doesn't care for amount let base_fee_numerator = base_fee_handler .get_base_fee_numerator_from_included_fee_amount( @@ -302,6 +318,8 @@ fn get_fee_handler( pool.activation_point, trade_direction, 0, + pool.pool_fees.init_sqrt_price, + pool.sqrt_price, )?; let total_fee_numerator = get_total_fee_numerator( @@ -310,7 +328,7 @@ fn get_fee_handler( max_fee_numerator, )?; Ok(FeeHandler { - rate_limiter_handler: FeeRateLimiter::default(), + rate_limiter_handler: PodAlignedFeeRateLimiter::default(), variable_fee_numerator, max_fee_numerator, total_fee_numerator, @@ -318,7 +336,7 @@ fn get_fee_handler( }) } BaseFeeMode::RateLimiter => { - let rate_limiter_handler = pool.pool_fees.base_fee.get_fee_rate_limiter()?; + let rate_limiter_handler = pool.pool_fees.base_fee.to_fee_rate_limiter()?; Ok(FeeHandler { rate_limiter_handler, total_fee_numerator: 0, diff --git a/tests/common/damm_v2.ts b/tests/common/damm_v2.ts index cb7336f..5975c5a 100644 --- a/tests/common/damm_v2.ts +++ b/tests/common/damm_v2.ts @@ -1,6 +1,7 @@ import { AnchorProvider, BN, + BorshCoder, IdlAccounts, IdlTypes, Program, @@ -168,7 +169,7 @@ export async function createDammV2Pool( tokenBMint: PublicKey, amountA?: BN, amountB?: BN, - baseFeeParams?: any + baseFeeParams?: Buffer ): Promise { const program = createDammV2Program(); @@ -217,17 +218,23 @@ export async function createDammV2Pool( liquidityDelta = BN.min(liquidityFromA, liquidityFromB); } + const baseFee = { + data: Array.from( + baseFeeParams ?? + encodeFeeTimeSchedulerParams( + new BN(2_500_000), + 0, + new BN(0), + new BN(0), + BaseFeeMode.FeeTimeSchedulerLinear + ) + ), + }; + const transaction = await program.methods .initializeCustomizablePool({ poolFees: { - baseFee: baseFeeParams ?? { - cliffFeeNumerator: new BN(2_500_000), - firstFactor: 0, - secondFactor: Array.from(new BN(0).toArrayLike(Buffer, "le", 8)), - thirdFactor: new BN(0), - baseFeeMode: 0, - }, - padding: [], + baseFee, dynamicFee: null, }, sqrtMinPrice: MIN_SQRT_PRICE, @@ -510,12 +517,76 @@ export async function swap(params: { .transaction(); } -export function convertToRateLimiterSecondFactor( - maxLimiterDuration: BN, - maxFeeBps: BN -): number[] { - const buffer1 = maxLimiterDuration.toArrayLike(Buffer, "le", 4); - const buffer2 = maxFeeBps.toArrayLike(Buffer, "le", 4); - const buffer = Buffer.concat([buffer1, buffer2]); - return Array.from(buffer); +const FEE_PADDING = Array.from(Buffer.alloc(3)); +const cpAmmCoder = new BorshCoder(CpAmmIDL as CpAmm); + +export enum BaseFeeMode { + FeeTimeSchedulerLinear, + FeeTimeSchedulerExponential, + RateLimiter, + FeeMarketCapSchedulerLinear, + FeeMarketCapSchedulerExponential, +} + +export function encodeFeeTimeSchedulerParams( + cliffFeeNumerator: BN, + numberOfPeriod: number, + periodFrequency: BN, + reductionFactor: BN, + baseFeeMode: BaseFeeMode +): Buffer { + const feeTimeScheduler = { + cliff_fee_numerator: new BN(cliffFeeNumerator.toString()), + number_of_period: numberOfPeriod, + period_frequency: new BN(periodFrequency.toString()), + reduction_factor: new BN(reductionFactor.toString()), + base_fee_mode: baseFeeMode, + padding: FEE_PADDING, + }; + + return cpAmmCoder.types.encode("BorshFeeTimeScheduler", feeTimeScheduler); +} + +export function encodeFeeMarketCapSchedulerParams( + cliffFeeNumerator: BN, + numberOfPeriod: number, + sqrtPriceStepBps: number, + schedulerExpirationDuration: number, + reductionFactor: BN, + baseFeeMode: BaseFeeMode +): Buffer { + const feeMarketCapScheduler = { + cliff_fee_numerator: new BN(cliffFeeNumerator.toString()), + number_of_period: numberOfPeriod, + sqrt_price_step_bps: sqrtPriceStepBps, + scheduler_expiration_duration: schedulerExpirationDuration, + reduction_factor: new BN(reductionFactor.toString()), + base_fee_mode: baseFeeMode, + padding: FEE_PADDING, + }; + + return cpAmmCoder.types.encode( + "BorshFeeMarketCapScheduler", + feeMarketCapScheduler + ); +} + +export function encodeFeeRateLimiterParams( + cliffFeeNumerator: BN, + feeIncrementBps: number, + maxLimiterDuration: number, + maxFeeBps: number, + referenceAmount: BN +): Buffer { + const feeRateLimiter = { + cliff_fee_numerator: new BN(cliffFeeNumerator.toString()), + fee_increment_bps: feeIncrementBps, + max_limiter_duration: maxLimiterDuration, + max_fee_bps: maxFeeBps, + reference_amount: new BN(referenceAmount.toString()), + base_fee_mode: BaseFeeMode.RateLimiter, + padding: FEE_PADDING, + }; + + return cpAmmCoder.types.encode("BorshFeeRateLimiter", feeRateLimiter); } diff --git a/tests/common/endpoints/zapIn.ts b/tests/common/endpoints/zapIn.ts index 8f6c7f1..869b273 100644 --- a/tests/common/endpoints/zapIn.ts +++ b/tests/common/endpoints/zapIn.ts @@ -4,6 +4,7 @@ import { AccountMeta, PublicKey, SystemProgram, + SYSVAR_INSTRUCTIONS_PUBKEY, Transaction, } from "@solana/web3.js"; import { DAMM_V2_PROGRAM_ID } from "../damm_v2"; @@ -14,15 +15,12 @@ import { deriveLedgerAccount, getDammV2Pool, } from "../pda"; -import { createZapProgram, ZAP_PROGRAM_ID } from "./zapOut"; +import { createZapProgram } from "./zapOut"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { DLMM_PROGRAM_ID_LOCAL, - getBinArrayAccountMetaByBinRange, getLbPairState, MEMO_PROGRAM_ID, - SET_COMPUTE_UNIT_LIMIT_IX, - StrategyType, } from "../dlmm"; export async function zapInDammv2(params: { @@ -87,6 +85,13 @@ export async function zapInDammv2(params: { dammProgram: DAMM_V2_PROGRAM_ID, dammEventAuthority: deriveDammV2EventAuthority(), }) + .remainingAccounts([ + { + isSigner: false, + isWritable: false, + pubkey: SYSVAR_INSTRUCTIONS_PUBKEY, + }, + ]) .transaction(); } diff --git a/tests/common/idl/damm_v2.ts b/tests/common/idl/damm_v2.ts index 3a1691c..df26138 100644 --- a/tests/common/idl/damm_v2.ts +++ b/tests/common/idl/damm_v2.ts @@ -8,7 +8,7 @@ export type CpAmm = { address: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"; metadata: { name: "cpAmm"; - version: "0.1.5"; + version: "0.1.7"; spec: "0.1.0"; description: "Created with Anchor"; }; @@ -356,195 +356,20 @@ export type CpAmm = { }, { name: "tokenAAccount"; - docs: ["The treasury token a account"]; 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: "account"; - path: "tokenAProgram"; - }, - { - kind: "account"; - path: "tokenAMint"; - } - ]; - 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: "tokenBAccount"; - docs: ["The treasury token b account"]; 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: "account"; - path: "tokenBProgram"; - }, - { - kind: "account"; - path: "tokenBMint"; - } - ]; - 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: "claimFeeOperator"; + name: "operator"; docs: ["Claim fee operator"]; }, { - name: "operator"; - docs: ["Operator"]; + name: "signer"; + docs: ["operator"]; signer: true; - relations: ["claimFeeOperator"]; }, { name: "tokenAProgram"; @@ -684,21 +509,24 @@ export type CpAmm = { ]; }, { - name: "closeClaimFeeOperator"; - discriminator: [38, 134, 82, 216, 95, 124, 17, 99]; + name: "closeConfig"; + discriminator: [145, 9, 72, 157, 95, 125, 61, 85]; accounts: [ { - name: "claimFeeOperator"; + name: "config"; writable: true; }, { - name: "rentReceiver"; - writable: true; + name: "operator"; }, { - name: "admin"; + name: "signer"; signer: true; }, + { + name: "rentReceiver"; + writable: true; + }, { name: "eventAuthority"; pda: { @@ -735,16 +563,15 @@ export type CpAmm = { args: []; }, { - name: "closeConfig"; - discriminator: [145, 9, 72, 157, 95, 125, 61, 85]; + name: "closeOperatorAccount"; + discriminator: [171, 9, 213, 74, 120, 23, 3, 29]; accounts: [ { - name: "config"; + name: "operator"; writable: true; }, { - name: "admin"; - writable: true; + name: "signer"; signer: true; }, { @@ -873,8 +700,10 @@ export type CpAmm = { writable: true; }, { - name: "admin"; - writable: true; + name: "operator"; + }, + { + name: "signer"; signer: true; }, { @@ -917,21 +746,22 @@ export type CpAmm = { args: []; }, { - name: "createClaimFeeOperator"; - discriminator: [169, 62, 207, 107, 58, 187, 162, 109]; + name: "createConfig"; + docs: ["OPERATOR FUNCTIONS /////"]; + discriminator: [201, 207, 243, 114, 75, 111, 47, 189]; accounts: [ { - name: "claimFeeOperator"; + name: "config"; writable: true; pda: { seeds: [ { kind: "const"; - value: [99, 102, 95, 111, 112, 101, 114, 97, 116, 111, 114]; + value: [99, 111, 110, 102, 105, 103]; }, { - kind: "account"; - path: "operator"; + kind: "arg"; + path: "index"; } ]; }; @@ -940,7 +770,11 @@ export type CpAmm = { name: "operator"; }, { - name: "admin"; + name: "signer"; + signer: true; + }, + { + name: "payer"; writable: true; signer: true; }, @@ -981,12 +815,24 @@ export type CpAmm = { name: "program"; } ]; - args: []; + args: [ + { + name: "index"; + type: "u64"; + }, + { + name: "configParameters"; + type: { + defined: { + name: "staticConfigParameters"; + }; + }; + } + ]; }, { - name: "createConfig"; - docs: ["ADMIN FUNCTIONS /////"]; - discriminator: [201, 207, 243, 114, 75, 111, 47, 189]; + name: "createDynamicConfig"; + discriminator: [81, 251, 122, 78, 66, 57, 208, 82]; accounts: [ { name: "config"; @@ -1005,7 +851,14 @@ export type CpAmm = { }; }, { - name: "admin"; + name: "operator"; + }, + { + name: "signer"; + signer: true; + }, + { + name: "payer"; writable: true; signer: true; }, @@ -1055,34 +908,42 @@ export type CpAmm = { name: "configParameters"; type: { defined: { - name: "staticConfigParameters"; + name: "dynamicConfigParameters"; }; }; } ]; }, { - name: "createDynamicConfig"; - discriminator: [81, 251, 122, 78, 66, 57, 208, 82]; + name: "createOperatorAccount"; + docs: ["ADMIN FUNCTIONS /////"]; + discriminator: [221, 64, 246, 149, 240, 153, 229, 163]; accounts: [ { - name: "config"; + name: "operator"; writable: true; pda: { seeds: [ { kind: "const"; - value: [99, 111, 110, 102, 105, 103]; + value: [111, 112, 101, 114, 97, 116, 111, 114]; }, { - kind: "arg"; - path: "index"; + kind: "account"; + path: "whitelistedAddress"; } ]; }; }, { - name: "admin"; + name: "whitelistedAddress"; + }, + { + name: "signer"; + signer: true; + }, + { + name: "payer"; writable: true; signer: true; }, @@ -1125,16 +986,8 @@ export type CpAmm = { ]; args: [ { - name: "index"; - type: "u64"; - }, - { - name: "configParameters"; - type: { - defined: { - name: "dynamicConfigParameters"; - }; - }; + name: "permission"; + type: "u128"; } ]; }, @@ -1289,7 +1142,14 @@ export type CpAmm = { name: "tokenMint"; }, { - name: "admin"; + name: "operator"; + }, + { + name: "signer"; + signer: true; + }, + { + name: "payer"; writable: true; signer: true; }, @@ -1332,6 +1192,31 @@ export type CpAmm = { ]; args: []; }, + { + name: "dummyIx"; + discriminator: [234, 95, 176, 185, 7, 42, 35, 159]; + accounts: [ + { + name: "podAlignedFeeTimeScheduler"; + }, + { + name: "podAlignedFeeRateLimiter"; + }, + { + name: "podAlignedFeeMarketCapScheduler"; + } + ]; + args: [ + { + name: "ixs"; + type: { + defined: { + name: "dummyParams"; + }; + }; + } + ]; + }, { name: "fundReward"; discriminator: [188, 50, 249, 165, 93, 151, 38, 63]; @@ -2539,7 +2424,10 @@ export type CpAmm = { writable: true; }, { - name: "admin"; + name: "operator"; + }, + { + name: "signer"; signer: true; }, { @@ -2952,6 +2840,65 @@ export type CpAmm = { } ]; }, + { + name: "updatePoolFees"; + discriminator: [118, 217, 203, 179, 60, 8, 70, 89]; + accounts: [ + { + name: "pool"; + writable: true; + }, + { + name: "operator"; + }, + { + name: "signer"; + signer: 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: "params"; + type: { + defined: { + name: "updatePoolFeesParameters"; + }; + }; + } + ]; + }, { name: "updateRewardDuration"; discriminator: [138, 174, 196, 169, 213, 235, 254, 107]; @@ -3133,42 +3080,98 @@ export type CpAmm = { type: "u8"; } ]; - } - ]; - accounts: [ - { - name: "claimFeeOperator"; - discriminator: [166, 48, 134, 86, 34, 200, 188, 150]; - }, - { - name: "config"; - discriminator: [155, 12, 170, 224, 30, 250, 204, 130]; - }, - { - name: "pool"; - discriminator: [241, 154, 109, 4, 17, 177, 109, 188]; - }, - { - name: "position"; - discriminator: [170, 188, 143, 228, 122, 64, 247, 208]; - }, - { - name: "tokenBadge"; - discriminator: [116, 219, 204, 229, 249, 116, 255, 150]; - }, - { - name: "vesting"; - discriminator: [100, 149, 66, 138, 95, 200, 128, 241]; - } - ]; - events: [ - { - name: "evtAddLiquidity"; - discriminator: [175, 242, 8, 157, 30, 247, 185, 169]; - }, - { - name: "evtClaimPartnerFee"; - discriminator: [118, 99, 77, 10, 226, 1, 1, 87]; + }, + { + name: "zapProtocolFee"; + discriminator: [213, 155, 187, 34, 56, 182, 91, 240]; + accounts: [ + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "pool"; + writable: true; + }, + { + name: "tokenVault"; + 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"]; + }, + { + name: "sysvarInstructions"; + address: "Sysvar1nstructions1111111111111111111111111"; + } + ]; + args: [ + { + name: "maxAmount"; + type: "u64"; + } + ]; + } + ]; + accounts: [ + { + name: "config"; + discriminator: [155, 12, 170, 224, 30, 250, 204, 130]; + }, + { + name: "operator"; + discriminator: [219, 31, 188, 145, 69, 139, 204, 117]; + }, + { + name: "podAlignedFeeMarketCapScheduler"; + discriminator: [251, 130, 208, 253, 245, 27, 145, 203]; + }, + { + name: "podAlignedFeeRateLimiter"; + discriminator: [160, 219, 8, 251, 179, 7, 16, 117]; + }, + { + name: "podAlignedFeeTimeScheduler"; + discriminator: [239, 132, 138, 213, 67, 154, 130, 70]; + }, + { + name: "pool"; + discriminator: [241, 154, 109, 4, 17, 177, 109, 188]; + }, + { + name: "position"; + discriminator: [170, 188, 143, 228, 122, 64, 247, 208]; + }, + { + name: "tokenBadge"; + discriminator: [116, 219, 204, 229, 249, 116, 255, 150]; + }, + { + name: "vesting"; + discriminator: [100, 149, 66, 138, 95, 200, 128, 241]; + } + ]; + events: [ + { + name: "evtClaimPartnerFee"; + discriminator: [118, 99, 77, 10, 226, 1, 1, 87]; }, { name: "evtClaimPositionFee"; @@ -3182,10 +3185,6 @@ export type CpAmm = { name: "evtClaimReward"; discriminator: [218, 86, 147, 200, 235, 188, 215, 231]; }, - { - name: "evtCloseClaimFeeOperator"; - discriminator: [111, 39, 37, 55, 110, 216, 194, 23]; - }, { name: "evtCloseConfig"; discriminator: [36, 30, 239, 45, 58, 132, 14, 5]; @@ -3194,10 +3193,6 @@ export type CpAmm = { name: "evtClosePosition"; discriminator: [20, 145, 144, 68, 143, 142, 214, 178]; }, - { - name: "evtCreateClaimFeeOperator"; - discriminator: [21, 6, 153, 120, 68, 116, 28, 177]; - }, { name: "evtCreateConfig"; discriminator: [131, 207, 180, 174, 180, 73, 165, 54]; @@ -3238,10 +3233,6 @@ export type CpAmm = { name: "evtPermanentLockPosition"; discriminator: [145, 143, 162, 218, 218, 80, 67, 11]; }, - { - name: "evtRemoveLiquidity"; - discriminator: [87, 46, 88, 98, 175, 96, 34, 91]; - }, { name: "evtSetPoolStatus"; discriminator: [100, 213, 74, 3, 95, 91, 228, 146]; @@ -3250,14 +3241,14 @@ export type CpAmm = { name: "evtSplitPosition2"; discriminator: [165, 32, 203, 174, 72, 100, 233, 103]; }, - { - name: "evtSwap"; - discriminator: [27, 60, 21, 213, 138, 170, 187, 147]; - }, { name: "evtSwap2"; discriminator: [189, 66, 51, 168, 38, 80, 117, 153]; }, + { + name: "evtUpdatePoolFees"; + discriminator: [76, 165, 246, 102, 102, 217, 156, 44]; + }, { name: "evtUpdateRewardDuration"; discriminator: [149, 135, 65, 231, 129, 153, 65, 57]; @@ -3524,7 +3515,7 @@ export type CpAmm = { }, { code: 6050; - name: "invalidFeeScheduler"; + name: "invalidFeeTimeScheduler"; msg: "Invalid fee scheduler"; }, { @@ -3536,6 +3527,76 @@ export type CpAmm = { code: 6052; name: "invalidPoolVersion"; msg: "Invalid pool version"; + }, + { + code: 6053; + name: "invalidAuthority"; + msg: "Invalid authority to do that action"; + }, + { + code: 6054; + name: "invalidPermission"; + msg: "Invalid permission"; + }, + { + code: 6055; + name: "invalidFeeMarketCapScheduler"; + msg: "Invalid fee market cap scheduler"; + }, + { + code: 6056; + name: "cannotUpdateBaseFee"; + msg: "Cannot update base fee"; + }, + { + code: 6057; + name: "invalidDynamicFeeParameters"; + msg: "Invalid dynamic fee parameters"; + }, + { + code: 6058; + name: "invalidUpdatePoolFeesParameters"; + msg: "Invalid update pool fees parameters"; + }, + { + code: 6059; + name: "missingOperatorAccount"; + msg: "Missing operator account"; + }, + { + code: 6060; + name: "incorrectAta"; + msg: "Incorrect ATA"; + }, + { + code: 6061; + name: "invalidZapOutParameters"; + msg: "Invalid zap out parameters"; + }, + { + code: 6062; + name: "invalidWithdrawProtocolFeeZapAccounts"; + msg: "Invalid withdraw protocol fee zap accounts"; + }, + { + code: 6063; + name: "mintRestrictedFromZap"; + msg: "SOL,USDC protocol fee cannot be withdrawn via zap"; + }, + { + code: 6064; + name: "cpiDisabled"; + msg: "CPI disabled"; + }, + { + code: 6065; + name: "missingZapOutInstruction"; + msg: "Missing zap out instruction"; + }, + { + code: 6066; + name: "invalidZapAccounts"; + msg: "Invalid zap accounts"; } ]; types: [ @@ -3563,7 +3624,7 @@ export type CpAmm = { }; }, { - name: "baseFeeConfig"; + name: "baseFeeInfo"; serialization: "bytemuck"; repr: { kind: "c"; @@ -3572,38 +3633,54 @@ export type CpAmm = { kind: "struct"; fields: [ { - name: "cliffFeeNumerator"; - type: "u64"; - }, - { - name: "baseFeeMode"; - type: "u8"; - }, - { - name: "padding"; + name: "data"; type: { - array: ["u8", 5]; + array: ["u8", 32]; }; - }, + } + ]; + }; + }, + { + name: "baseFeeParameters"; + type: { + kind: "struct"; + fields: [ { - name: "firstFactor"; - type: "u16"; - }, + name: "data"; + type: { + array: ["u8", 30]; + }; + } + ]; + }; + }, + { + name: "baseFeeStruct"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ { - name: "secondFactor"; + name: "baseFeeInfo"; type: { - array: ["u8", 8]; + defined: { + name: "baseFeeInfo"; + }; }; }, { - name: "thirdFactor"; + name: "padding1"; type: "u64"; } ]; }; }, { - name: "baseFeeParameters"; + name: "borshFeeMarketCapScheduler"; type: { kind: "struct"; fields: [ @@ -3612,32 +3689,49 @@ export type CpAmm = { type: "u64"; }, { - name: "firstFactor"; + name: "numberOfPeriod"; type: "u16"; }, { - name: "secondFactor"; - type: { - array: ["u8", 8]; - }; + name: "sqrtPriceStepBps"; + type: "u32"; }, { - name: "thirdFactor"; + name: "schedulerExpirationDuration"; + type: "u32"; + }, + { + name: "reductionFactor"; type: "u64"; }, { name: "baseFeeMode"; type: "u8"; + }, + { + name: "padding"; + type: { + array: ["u8", 3]; + }; } ]; }; }, { - name: "baseFeeStruct"; - serialization: "bytemuck"; - repr: { - kind: "c"; - }; + name: "borshFeeRateLimiter"; + docs: [ + "we denote reference_amount = x0, cliff_fee_numerator = c, fee_increment = i", + "if input_amount <= x0, then fee = input_amount * c", + "", + "if input_amount > x0, then input_amount = x0 + (a * x0 + b)", + "if a < max_index", + "then fee = x0 * c + x0 * (c + i) + .... + x0 * (c + i*a) + b * (c + i * (a+1))", + "then fee = x0 * (c + c*a + i*a*(a+1)/2) + b * (c + i * (a+1))", + "", + "if a >= max_index", + "if a = max_index + d, input_amount = x0 + max_index * x0 + (d * x0 + b)", + "then fee = x0 * (c + c*max_index + i*max_index*(max_index+1)/2) + (d * x0 + b) * MAX_FEE" + ]; type: { kind: "struct"; fields: [ @@ -3646,56 +3740,63 @@ export type CpAmm = { type: "u64"; }, { - name: "baseFeeMode"; - type: "u8"; + name: "feeIncrementBps"; + type: "u16"; }, { - name: "padding0"; - type: { - array: ["u8", 5]; - }; + name: "maxLimiterDuration"; + type: "u32"; }, { - name: "firstFactor"; - type: "u16"; + name: "maxFeeBps"; + type: "u32"; }, { - name: "secondFactor"; - type: { - array: ["u8", 8]; - }; + name: "referenceAmount"; + type: "u64"; }, { - name: "thirdFactor"; - type: "u64"; + name: "baseFeeMode"; + type: "u8"; }, { - name: "padding1"; - type: "u64"; + name: "padding"; + type: { + array: ["u8", 3]; + }; } ]; }; }, { - name: "claimFeeOperator"; - docs: ["Parameter that set by the protocol"]; - serialization: "bytemuck"; - repr: { - kind: "c"; - }; + name: "borshFeeTimeScheduler"; type: { kind: "struct"; fields: [ { - name: "operator"; - docs: ["operator"]; - type: "pubkey"; + name: "cliffFeeNumerator"; + type: "u64"; + }, + { + name: "numberOfPeriod"; + type: "u16"; + }, + { + name: "periodFrequency"; + type: "u64"; + }, + { + name: "reductionFactor"; + type: "u64"; + }, + { + name: "baseFeeMode"; + type: "u8"; }, { name: "padding"; - docs: ["Reserve"]; type: { - array: ["u8", 128]; + array: ["u8", 3]; }; } ]; @@ -3778,6 +3879,38 @@ export type CpAmm = { ]; }; }, + { + name: "dummyParams"; + type: { + kind: "struct"; + fields: [ + { + name: "borshFeeTimeSchedulerParams"; + type: { + defined: { + name: "borshFeeTimeScheduler"; + }; + }; + }, + { + name: "borshFeeRateLimiterParams"; + type: { + defined: { + name: "borshFeeRateLimiter"; + }; + }; + }, + { + name: "borshFeeMarketCapSchedulerParams"; + type: { + defined: { + name: "borshFeeMarketCapScheduler"; + }; + }; + } + ]; + }; + }, { name: "dynamicConfigParameters"; type: { @@ -3948,50 +4081,6 @@ export type CpAmm = { ]; }; }, - { - name: "evtAddLiquidity"; - type: { - kind: "struct"; - fields: [ - { - name: "pool"; - type: "pubkey"; - }, - { - name: "position"; - type: "pubkey"; - }, - { - name: "owner"; - type: "pubkey"; - }, - { - name: "params"; - type: { - defined: { - name: "addLiquidityParameters"; - }; - }; - }, - { - name: "tokenAAmount"; - type: "u64"; - }, - { - name: "tokenBAmount"; - type: "u64"; - }, - { - name: "totalAmountA"; - type: "u64"; - }, - { - name: "totalAmountB"; - type: "u64"; - } - ]; - }; - }, { name: "evtClaimPartnerFee"; type: { @@ -4092,23 +4181,6 @@ export type CpAmm = { ]; }; }, - { - name: "evtCloseClaimFeeOperator"; - docs: ["Close claim fee operator"]; - type: { - kind: "struct"; - fields: [ - { - name: "claimFeeOperator"; - type: "pubkey"; - }, - { - name: "operator"; - type: "pubkey"; - } - ]; - }; - }, { name: "evtCloseConfig"; docs: ["Close config"]; @@ -4152,19 +4224,6 @@ export type CpAmm = { ]; }; }, - { - name: "evtCreateClaimFeeOperator"; - docs: ["Create claim fee operator"]; - type: { - kind: "struct"; - fields: [ - { - name: "operator"; - type: "pubkey"; - } - ]; - }; - }, { name: "evtCreateConfig"; docs: ["Create static config"]; @@ -4572,42 +4631,6 @@ export type CpAmm = { ]; }; }, - { - name: "evtRemoveLiquidity"; - type: { - kind: "struct"; - fields: [ - { - name: "pool"; - type: "pubkey"; - }, - { - name: "position"; - type: "pubkey"; - }, - { - name: "owner"; - type: "pubkey"; - }, - { - name: "params"; - type: { - defined: { - name: "removeLiquidityParameters"; - }; - }; - }, - { - name: "tokenAAmount"; - type: "u64"; - }, - { - name: "tokenBAmount"; - type: "u64"; - } - ]; - }; - }, { name: "evtSetPoolStatus"; type: { @@ -4688,50 +4711,6 @@ export type CpAmm = { ]; }; }, - { - name: "evtSwap"; - type: { - kind: "struct"; - fields: [ - { - name: "pool"; - type: "pubkey"; - }, - { - name: "tradeDirection"; - type: "u8"; - }, - { - name: "hasReferral"; - type: "bool"; - }, - { - name: "params"; - type: { - defined: { - name: "swapParameters"; - }; - }; - }, - { - name: "swapResult"; - type: { - defined: { - name: "swapResult"; - }; - }; - }, - { - name: "actualAmountIn"; - type: "u64"; - }, - { - name: "currentTimestamp"; - type: "u64"; - } - ]; - }; - }, { name: "evtSwap2"; type: { @@ -4786,12 +4765,36 @@ export type CpAmm = { type: "u64"; }, { - name: "reserveAAmount"; - type: "u64"; + name: "reserveAAmount"; + type: "u64"; + }, + { + name: "reserveBAmount"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtUpdatePoolFees"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "operator"; + type: "pubkey"; }, { - name: "reserveBAmount"; - type: "u64"; + name: "params"; + type: { + defined: { + name: "updatePoolFeesParameters"; + }; + }; } ]; }; @@ -4901,7 +4904,7 @@ export type CpAmm = { { name: "sqrtPrice"; docs: [ - "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value" + "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value. Market cap fee scheduler minimum price will be derived from this value" ]; type: "u128"; }, @@ -4952,6 +4955,154 @@ export type CpAmm = { ]; }; }, + { + 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: "podAlignedFeeMarketCapScheduler"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "cliffFeeNumerator"; + type: "u64"; + }, + { + name: "baseFeeMode"; + type: "u8"; + }, + { + name: "padding"; + type: { + array: ["u8", 5]; + }; + }, + { + name: "numberOfPeriod"; + type: "u16"; + }, + { + name: "sqrtPriceStepBps"; + type: "u32"; + }, + { + name: "schedulerExpirationDuration"; + type: "u32"; + }, + { + name: "reductionFactor"; + type: "u64"; + } + ]; + }; + }, + { + name: "podAlignedFeeRateLimiter"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "cliffFeeNumerator"; + type: "u64"; + }, + { + name: "baseFeeMode"; + type: "u8"; + }, + { + name: "padding"; + type: { + array: ["u8", 5]; + }; + }, + { + name: "feeIncrementBps"; + type: "u16"; + }, + { + name: "maxLimiterDuration"; + type: "u32"; + }, + { + name: "maxFeeBps"; + type: "u32"; + }, + { + name: "referenceAmount"; + type: "u64"; + } + ]; + }; + }, + { + name: "podAlignedFeeTimeScheduler"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "cliffFeeNumerator"; + type: "u64"; + }, + { + name: "baseFeeMode"; + type: "u8"; + }, + { + name: "padding"; + type: { + array: ["u8", 5]; + }; + }, + { + name: "numberOfPeriod"; + type: "u16"; + }, + { + name: "periodFrequency"; + type: "u64"; + }, + { + name: "reductionFactor"; + type: "u64"; + } + ]; + }; + }, { name: "pool"; serialization: "bytemuck"; @@ -5077,7 +5228,7 @@ export type CpAmm = { { name: "collectFeeMode"; docs: [ - "0 is collect fee in both token, 1 only collect fee in token a, 2 only collect fee in token b" + "0 is collect fee in both token, 1 only collect fee only in token b" ]; type: "u8"; }, @@ -5169,13 +5320,6 @@ export type CpAmm = { }; }; }, - { - name: "padding"; - docs: ["padding"]; - type: { - array: ["u8", 3]; - }; - }, { name: "dynamicFee"; docs: ["dynamic fee"]; @@ -5203,7 +5347,7 @@ export type CpAmm = { name: "baseFee"; type: { defined: { - name: "baseFeeConfig"; + name: "baseFeeInfo"; }; }; }, @@ -5308,11 +5452,8 @@ export type CpAmm = { }; }, { - name: "padding1"; - docs: ["padding"]; - type: { - array: ["u64", 2]; - }; + name: "initSqrtPrice"; + type: "u128"; } ]; }; @@ -5813,39 +5954,6 @@ export type CpAmm = { ]; }; }, - { - name: "swapResult"; - docs: ["Encodes all results of swapping"]; - type: { - kind: "struct"; - fields: [ - { - name: "outputAmount"; - type: "u64"; - }, - { - name: "nextSqrtPrice"; - type: "u128"; - }, - { - name: "lpFee"; - type: "u64"; - }, - { - name: "protocolFee"; - type: "u64"; - }, - { - name: "partnerFee"; - type: "u64"; - }, - { - name: "referralFee"; - type: "u64"; - } - ]; - }; - }, { name: "swapResult2"; type: { @@ -5915,6 +6023,41 @@ export type CpAmm = { ]; }; }, + { + name: "updatePoolFeesParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "cliffFeeNumerator"; + docs: [ + "Base fee update mode:", + "- None: skip base fee update", + "- Some: update new cliff_fee_numerator if base fee is static" + ]; + type: { + option: "u64"; + }; + }, + { + name: "dynamicFee"; + docs: [ + "Dynamic fee update mode:", + "- None: skip dynamic fee update", + "- Some(with default value): disable dynamic fee", + "- Some(with non default value): enable dynamic fee if disabled or update dynamic fee if enabled" + ]; + type: { + option: { + defined: { + name: "dynamicFeeParameters"; + }; + }; + }; + } + ]; + }; + }, { name: "userRewardInfo"; serialization: "bytemuck"; @@ -6027,4 +6170,81 @@ export type CpAmm = { }; } ]; + constants: [ + { + name: "binStepBpsDefault"; + type: "u16"; + value: "1"; + }, + { + name: "binStepU128DefaultLeBytes"; + type: { + array: ["u8", 16]; + }; + value: "[203, 16, 199, 186, 184, 141, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0]"; + }, + { + name: "customizablePoolPrefix"; + type: "bytes"; + value: "[99, 112, 111, 111, 108]"; + }, + { + name: "feeDenominator"; + docs: [ + "Default fee denominator. DO NOT simply update it as it will break logic that depends on it as default value." + ]; + type: "u64"; + value: "1000000000"; + }, + { + name: "maxBasisPoint"; + docs: ["Max basis point. 100% in pct"]; + type: "u64"; + value: "10000"; + }, + { + name: "maxSqrtPriceLeBytes"; + type: { + array: ["u8", 16]; + }; + value: "[155, 87, 105, 78, 169, 26, 92, 132, 177, 196, 254, 255, 0, 0, 0, 0]"; + }, + { + name: "minSqrtPriceLeBytes"; + type: { + array: ["u8", 16]; + }; + value: "[80, 59, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"; + }, + { + name: "poolAuthorityPrefix"; + type: "bytes"; + value: "[112, 111, 111, 108, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]"; + }, + { + name: "poolPrefix"; + type: "bytes"; + value: "[112, 111, 111, 108]"; + }, + { + name: "positionNftAccountPrefix"; + type: "bytes"; + value: "[112, 111, 115, 105, 116, 105, 111, 110, 95, 110, 102, 116, 95, 97, 99, 99, 111, 117, 110, 116]"; + }, + { + name: "positionPrefix"; + type: "bytes"; + value: "[112, 111, 115, 105, 116, 105, 111, 110]"; + }, + { + name: "splitPositionDenominator"; + type: "u32"; + value: "1000000000"; + }, + { + name: "tokenVaultPrefix"; + type: "bytes"; + value: "[116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116]"; + } + ]; }; diff --git a/tests/common/utils.ts b/tests/common/utils.ts index 8cdc070..c1d6dca 100644 --- a/tests/common/utils.ts +++ b/tests/common/utils.ts @@ -36,6 +36,7 @@ export const MAX_SQRT_PRICE = new BN("79226673521066979257578248091"); export const LIQUIDITY_DELTA = new BN("1844674407800459963300003758876517305"); export const INIT_PRICE = new BN("18446744073709551616"); export const LIQUIDITY_DELTA_2 = new BN("18446744078004599633000037588765"); +export const U32_MAX = new BN("4294967295"); export const U64_MAX = new BN("18446744073709551615"); export function createToken( diff --git a/tests/fixtures/damm_v2.so b/tests/fixtures/damm_v2.so index abd3200..fe1ed6b 100755 Binary files a/tests/fixtures/damm_v2.so and b/tests/fixtures/damm_v2.so differ diff --git a/tests/test_zapin/zapin_dammv2.test.ts b/tests/test_zapin/zapin_dammv2.test.ts index 7416629..5862ec0 100644 --- a/tests/test_zapin/zapin_dammv2.test.ts +++ b/tests/test_zapin/zapin_dammv2.test.ts @@ -23,12 +23,12 @@ import { warpSlotBy, TOKEN_DECIMALS, U64_MAX, + U32_MAX, } from "../common"; import ZapIDL from "../../target/idl/zap.json"; import DAMMV2IDL from "../../idls/damm_v2.json"; import { - convertToRateLimiterSecondFactor, createDammV2Pool, createDammV2Position, swap, @@ -37,12 +37,16 @@ import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { BN } from "@coral-xyz/anchor"; import { getDammV2Pool, getDammV2Position } from "../common/pda"; import { expect } from "chai"; -import fs from "fs"; +import { + BaseFeeMode, + encodeFeeMarketCapSchedulerParams, + encodeFeeRateLimiterParams, + encodeFeeTimeSchedulerParams, +} from "../common/damm_v2"; describe("Zap In damm V2", () => { let zapProgram: ZapProgram; let svm: LiteSVM; - let tokenMint: PublicKey; let user: Keypair; let admin: Keypair; let tokenAMint: PublicKey; @@ -97,15 +101,55 @@ describe("Zap In damm V2", () => { }); }); - it("zap in with pool has fee scheduler", async () => { - const baseFee = { - cliffFeeNumerator: new BN(500_000_000), // 50 % - firstFactor: 100, // 100 periods - secondFactor: Array.from(new BN(1).toArrayLike(Buffer, "le", 8)), - thirdFactor: new BN(4875000), - baseFeeMode: 0, // fee scheduler Linear mode - }; + it("zap in with pool has fee time scheduler linear", async () => { + const baseFee = encodeFeeTimeSchedulerParams( + new BN(500_000_000), // 50% cliff fee + 100, // 100 periods + new BN(1), // period frequency in slots + new BN(4875000), // 0.4875% reduction per period + BaseFeeMode.FeeTimeSchedulerLinear + ); + warpSlotBy(svm, new BN(10)); + + const pool = await createDammV2Pool( + svm, + admin, + tokenAMint, + tokenBMint, + undefined, + undefined, + baseFee + ); + + const { position, positionNftAccount } = await createDammV2Position( + svm, + user, + pool + ); + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + await zapInFullFlow({ + svm, + user, + pool, + position, + positionNftAccount, + inputTokenMint: tokenAMint, + outputTokenMint: tokenBMint, + totalAmount: amountTokenA, + amountSwap, + }); + }); + + it("zap in with pool has fee time scheduler exponential", async () => { + const baseFee = encodeFeeTimeSchedulerParams( + new BN(990_000_000), // 99% cliff fee + 10, // 10 periods + new BN(1), // period frequency in slots + new BN(1_000), // 10% decay per period + BaseFeeMode.FeeTimeSchedulerExponential + ); warpSlotBy(svm, new BN(10)); const pool = await createDammV2Pool( @@ -140,18 +184,13 @@ describe("Zap In damm V2", () => { }); it("zap in with pool has rate limiter", async () => { - let maxRateLimiterDuration = new BN(10); - let maxFeeBps = new BN(5000); - const baseFee = { - cliffFeeNumerator: new BN(10_000_000), // 100bps - firstFactor: 10, // 10 bps - secondFactor: convertToRateLimiterSecondFactor( - maxRateLimiterDuration, - maxFeeBps - ), - thirdFactor: new BN(LAMPORTS_PER_SOL), // 1 SOL, - baseFeeMode: 2, // rate limiter mode - }; + const baseFee = encodeFeeRateLimiterParams( + new BN(10_000_000), // 1% cliff fee + 10, // 10 bps fee increment + 10, // max limiter duration + 5000, // 50% max fee + new BN(LAMPORTS_PER_SOL) // reference amount: 1 SOL + ); const pool = await createDammV2Pool( svm, @@ -184,6 +223,88 @@ describe("Zap In damm V2", () => { }); }); + it("zap in with pool has fee market cap scheduler linear", async () => { + const baseFee = encodeFeeMarketCapSchedulerParams( + new BN(50_000_000), // 5% cliff fee + 20, // 20 periods + 50, // 0.5% price step + 5000, // scheduler expires after 5000 slots + new BN(1_000_000), // 0.1% reduction per period + BaseFeeMode.FeeMarketCapSchedulerLinear + ); + + const pool = await createDammV2Pool( + svm, + admin, + tokenAMint, + tokenBMint, + undefined, + undefined, + baseFee + ); + + const { position, positionNftAccount } = await createDammV2Position( + svm, + user, + pool + ); + + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + await zapInFullFlow({ + svm, + user, + pool, + position, + positionNftAccount, + inputTokenMint: tokenAMint, + outputTokenMint: tokenBMint, + totalAmount: amountTokenA, + amountSwap, + }); + }); + + it("zap in with pool has fee market cap scheduler exponential", async () => { + const baseFee = encodeFeeMarketCapSchedulerParams( + new BN(990_000_000), // 99% cliff fee + 10, // 10 periods + 50, // 0.5% sqrt price step between tiers (in bps) + 1000, // scheduler expires after 1000 slots + new BN(1_000), // 10% decay per period (1000/10000 in bps scale) + BaseFeeMode.FeeMarketCapSchedulerExponential + ); + + const pool = await createDammV2Pool( + svm, + admin, + tokenAMint, + tokenBMint, + undefined, + undefined, + baseFee + ); + + const { position, positionNftAccount } = await createDammV2Position( + svm, + user, + pool + ); + + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + await zapInFullFlow({ + svm, + user, + pool, + position, + positionNftAccount, + inputTokenMint: tokenAMint, + outputTokenMint: tokenBMint, + totalAmount: amountTokenA, + amountSwap, + }); + }); + it("zap in with pool low liquidity", async () => { const pool = await createDammV2Pool( svm, @@ -258,7 +379,6 @@ describe("Zap In damm V2", () => { ); // zapin - const zapInTx = await zapInDammv2({ svm, user: user.publicKey, @@ -269,7 +389,88 @@ describe("Zap In damm V2", () => { maxSqrtPriceChangeBps: 5000, }); - // close ledge + // close ledger + const closeLedgerTx = await closeLedgerAccount(user.publicKey); + + const finalTx = new Transaction() + .add(initializeLedgerTx) + .add(setLedgerBalanceTx) + .add(updateLedgerBalanceAfterSwapTx) + .add(zapInTx) + .add(closeLedgerTx); + + finalTx.recentBlockhash = svm.latestBlockhash(); + finalTx.sign(user); + + const result = svm.sendTransaction(finalTx); + if (result instanceof FailedTransactionMetadata) { + console.log(result.meta().logs()); + } + expect(result).instanceOf(TransactionMetadata); + }); + + it("zap in without external swap with rate limiter and remaining accounts", async () => { + const baseFee = encodeFeeRateLimiterParams( + new BN(10_000_00), // 1% cliff fee + 1, // 10 bps fee increment + 10, // max limiter duration + 5000, // 50% max fee + new BN(LAMPORTS_PER_SOL) // reference amount: 1 SOL + ); + + const pool = await createDammV2Pool( + svm, + admin, + tokenAMint, + tokenBMint, + new BN(LAMPORTS_PER_SOL), + new BN(LAMPORTS_PER_SOL), + baseFee + ); + + const { position, positionNftAccount } = await createDammV2Position( + svm, + user, + pool + ); + + let poolState = getDammV2Pool(svm, pool); + + const totalAmountB = new BN(LAMPORTS_PER_SOL / 2); // 0.5 SOL + const initializeLedgerTx = await initializeLedgerAccount(user.publicKey); + + // swap BtoA to trigger remaining account validation in dammv2 + const setLedgerBalanceTx = await setLedgerBalance( + user.publicKey, + totalAmountB, + false + ); + + const tokenAAccount = getAssociatedTokenAddressSync( + tokenAMint, + user.publicKey + ); + + const updateLedgerBalanceAfterSwapTx = await updateLedgerBalanceAfterSwap( + user.publicKey, + tokenAAccount, + new BN(0), // no token A + U64_MAX, + false + ); + + // zapin + const zapInTx = await zapInDammv2({ + svm, + user: user.publicKey, + pool, + position, + positionNftAccount, + preSqrtPrice: poolState.sqrtPrice, + maxSqrtPriceChangeBps: U32_MAX.toNumber(), + }); + + // close ledger const closeLedgerTx = await closeLedgerAccount(user.publicKey); const finalTx = new Transaction()