diff --git a/.github/actions/setup-anchor/action.yml b/.github/actions/setup-anchor/action.yml new file mode 100644 index 0000000..38ee8d2 --- /dev/null +++ b/.github/actions/setup-anchor/action.yml @@ -0,0 +1,10 @@ +name: "Setup anchor-cli" +description: "Setup node js and anchor cli" +runs: + using: "composite" + steps: + - uses: actions/setup-node@v2 + with: + node-version: ${{ env.NODE_VERSION }} + - run: cargo install --git https://github.com/coral-xyz/anchor --tag v${{ env.ANCHOR_CLI_VERSION }} anchor-cli --locked + shell: bash diff --git a/.github/actions/setup-dep/action.yml b/.github/actions/setup-dep/action.yml new file mode 100644 index 0000000..fa998c5 --- /dev/null +++ b/.github/actions/setup-dep/action.yml @@ -0,0 +1,7 @@ +name: "Setup" +description: "Setup program dependencies" +runs: + using: "composite" + steps: + - run: sudo apt-get update && sudo apt-get install -y pkg-config build-essential libudev-dev + shell: bash diff --git a/.github/actions/setup-solana/action.yml b/.github/actions/setup-solana/action.yml new file mode 100644 index 0000000..f4e60ac --- /dev/null +++ b/.github/actions/setup-solana/action.yml @@ -0,0 +1,21 @@ +name: "Setup Solana" +description: "Setup Solana" +runs: + using: "composite" + steps: + - uses: actions/cache@v4 + name: Cache Solana Tool Suite + id: cache-solana + with: + path: | + ~/.cache/solana/ + ~/.local/share/solana/ + key: solana-${{ runner.os }}-v0000-${{ env.SOLANA_CLI_VERSION }} + - run: sh -c "$(curl -sSfL https://release.anza.xyz/v${{ env.SOLANA_CLI_VERSION }}/install)" + shell: bash + - run: echo "$HOME/.local/share/solana/install/active_release/bin/" >> $GITHUB_PATH + shell: bash + - run: solana-keygen new --no-bip39-passphrase + shell: bash + - run: solana config set --url localhost + shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..23a9663 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,76 @@ +name: Dynamic-Fee-Sharing + +on: + pull_request: + branches: + - main + - release_0.1.1 + +env: + SOLANA_CLI_VERSION: 2.1.0 + NODE_VERSION: 22.15.0 + ANCHOR_CLI_VERSION: 0.31.0 + TOOLCHAIN: 1.76.0 + +jobs: + program_changed_files: + runs-on: ubuntu-latest + outputs: + program: ${{steps.changed-files-specific.outputs.any_changed}} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Get specific changed files + id: changed-files-specific + uses: tj-actions/changed-files@v18.6 + with: + files: | + programs/dynamic-fee-sharing + + cargo_test: + runs-on: ubuntu-latest + needs: program_changed_files + if: needs.program_changed_files.outputs.program == 'true' + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.TOOLCHAIN }} + components: clippy + # Cache rust, cargo + - uses: Swatinem/rust-cache@v1 + - run: cargo test --package dynamic-fee-sharing + shell: bash + + program_test: + runs-on: ubuntu-latest + needs: program_changed_files + if: needs.program_changed_files.outputs.program == 'true' + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup-solana + - uses: ./.github/actions/setup-dep + - uses: ./.github/actions/setup-anchor + # Install pnpm + - uses: pnpm/action-setup@v3 # docs https://pnpm.io/continuous-integration#github-actions + with: + version: 9.5.0 # Optional: specify a pnpm version + # Install rust + toolchain + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.TOOLCHAIN }} + components: clippy + # Cache rust, cargo + - uses: Swatinem/rust-cache@v1 + # Cache node_modules + - uses: actions/cache@v4 + id: cache-node-modules + with: + path: ./node_modules + key: ${{ runner.os }}-${{ hashFiles('./package-lock.json') }} + # Testing + - run: pnpm install + shell: bash + - run: pnpm test + shell: bash diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f9f71e3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,29 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +### Changed + +### Deprecated + +### Removed + +### Fixed + +### Security + +### Breaking Changes + +## dynamic-fee-sharing [0.1.1] [PR #8](https://github.com/MeteoraAg/dynamic-fee-sharing/pull/8) + +### Added +- Add new field `fee_vault_type` in `FeeVault` to distinguish between PDA-derived and keypair-derived fee vaults. +- Add new endpoint `fund_by_claiming_fee`, that allow share holder in fee vault to claim fees from whitelisted endpoints of DAMM-v2 or Dynamic Bonding Curve + diff --git a/Cargo.lock b/Cargo.lock index 7c036ef..2fd7928 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -712,6 +712,16 @@ dependencies = [ "web-sys", ] +[[package]] +name = "const-crypto" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c06f1eb05f06cf2e380fdded278fbf056a38974299d77960555a311dcf91a52" +dependencies = [ + "keccak-const", + "sha2-const-stable", +] + [[package]] name = "constant_time_eq" version = "0.3.1" @@ -782,6 +792,14 @@ dependencies = [ "syn 2.0.98", ] +[[package]] +name = "damm-v2" +version = "0.1.3" +dependencies = [ + "anchor-lang", + "bytemuck", +] + [[package]] name = "derivation-path" version = "0.2.0" @@ -819,13 +837,24 @@ dependencies = [ "subtle", ] +[[package]] +name = "dynamic-bonding-curve" +version = "0.1.6" +dependencies = [ + "anchor-lang", + "bytemuck", +] + [[package]] name = "dynamic-fee-sharing" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anchor-lang", "anchor-spl", "bytemuck", + "const-crypto", + "damm-v2", + "dynamic-bonding-curve", "num_enum", "proptest", "ruint", @@ -1100,6 +1129,12 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "keccak-const" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d8d8ce877200136358e0bbff3a77965875db3af755a11e1fa6b1b3e2df13ea" + [[package]] name = "lazy_static" version = "1.5.0" @@ -1834,6 +1869,12 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sha2-const-stable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f179d4e11094a893b82fff208f74d448a7512f99f5a0acbd5c679b705f83ed9" + [[package]] name = "sha3" version = "0.10.8" diff --git a/Cargo.toml b/Cargo.toml index f397704..e80623e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,3 +12,8 @@ codegen-units = 1 opt-level = 3 incremental = false codegen-units = 1 + +[workspace.dependencies] +anchor-lang = {version = "0.31.1", features = ["event-cpi"]} +anchor-spl = "0.31.1" +bytemuck = { version = "1.20.0", features = ["derive", "min_const_generics"] } diff --git a/idls/damm_v2.json b/idls/damm_v2.json new file mode 100644 index 0000000..62095b1 --- /dev/null +++ b/idls/damm_v2.json @@ -0,0 +1,6892 @@ +{ + "address": "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG", + "metadata": { + "name": "cp_amm", + "version": "0.1.3", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "add_liquidity", + "discriminator": [ + 181, + 157, + 89, + 67, + 143, + 182, + 52, + 72 + ], + "accounts": [ + { + "name": "pool", + "writable": true, + "relations": [ + "position" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "token_a_account", + "docs": [ + "The user token a account" + ], + "writable": true + }, + { + "name": "token_b_account", + "docs": [ + "The user token b account" + ], + "writable": true + }, + { + "name": "token_a_vault", + "docs": [ + "The vault token account for input token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_b_vault", + "docs": [ + "The vault token account for output token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_a_mint", + "docs": [ + "The mint of token a" + ], + "relations": [ + "pool" + ] + }, + { + "name": "token_b_mint", + "docs": [ + "The mint of token b" + ], + "relations": [ + "pool" + ] + }, + { + "name": "position_nft_account", + "docs": [ + "The token account for nft" + ] + }, + { + "name": "owner", + "docs": [ + "owner of position" + ], + "signer": true + }, + { + "name": "token_a_program", + "docs": [ + "Token a program" + ] + }, + { + "name": "token_b_program", + "docs": [ + "Token b program" + ] + }, + { + "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": "params", + "type": { + "defined": { + "name": "AddLiquidityParameters" + } + } + } + ] + }, + { + "name": "claim_partner_fee", + "discriminator": [ + 97, + 206, + 39, + 105, + 94, + 94, + 126, + 148 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "pool", + "writable": true + }, + { + "name": "token_a_account", + "docs": [ + "The treasury token a account" + ], + "writable": true + }, + { + "name": "token_b_account", + "docs": [ + "The treasury token b account" + ], + "writable": true + }, + { + "name": "token_a_vault", + "docs": [ + "The vault token account for input token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_b_vault", + "docs": [ + "The vault token account for output token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_a_mint", + "docs": [ + "The mint of token a" + ], + "relations": [ + "pool" + ] + }, + { + "name": "token_b_mint", + "docs": [ + "The mint of token b" + ], + "relations": [ + "pool" + ] + }, + { + "name": "partner", + "signer": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_a_program", + "docs": [ + "Token a program" + ] + }, + { + "name": "token_b_program", + "docs": [ + "Token b program" + ] + }, + { + "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": "max_amount_a", + "type": "u64" + }, + { + "name": "max_amount_b", + "type": "u64" + } + ] + }, + { + "name": "claim_position_fee", + "discriminator": [ + 180, + 38, + 154, + 17, + 133, + 33, + 162, + 211 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "pool", + "relations": [ + "position" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "token_a_account", + "docs": [ + "The user token a account" + ], + "writable": true + }, + { + "name": "token_b_account", + "docs": [ + "The user token b account" + ], + "writable": true + }, + { + "name": "token_a_vault", + "docs": [ + "The vault token account for input token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_b_vault", + "docs": [ + "The vault token account for output token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_a_mint", + "docs": [ + "The mint of token a" + ], + "relations": [ + "pool" + ] + }, + { + "name": "token_b_mint", + "docs": [ + "The mint of token b" + ], + "relations": [ + "pool" + ] + }, + { + "name": "position_nft_account", + "docs": [ + "The token account for nft" + ] + }, + { + "name": "owner", + "docs": [ + "owner of position" + ], + "signer": true + }, + { + "name": "token_a_program", + "docs": [ + "Token a program" + ] + }, + { + "name": "token_b_program", + "docs": [ + "Token b program" + ] + }, + { + "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": "claim_protocol_fee", + "discriminator": [ + 165, + 228, + 133, + 48, + 99, + 249, + 255, + 33 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "pool", + "writable": true + }, + { + "name": "token_a_vault", + "docs": [ + "The vault token account for input token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_b_vault", + "docs": [ + "The vault token account for output token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_a_mint", + "docs": [ + "The mint of token a" + ], + "relations": [ + "pool" + ] + }, + { + "name": "token_b_mint", + "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 + ] + } + } + }, + { + "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 + ] + } + } + }, + { + "name": "claim_fee_operator", + "docs": [ + "Claim fee operator" + ] + }, + { + "name": "operator", + "docs": [ + "Operator" + ], + "signer": true, + "relations": [ + "claim_fee_operator" + ] + }, + { + "name": "token_a_program", + "docs": [ + "Token a program" + ] + }, + { + "name": "token_b_program", + "docs": [ + "Token b program" + ] + }, + { + "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": "max_amount_a", + "type": "u64" + }, + { + "name": "max_amount_b", + "type": "u64" + } + ] + }, + { + "name": "claim_reward", + "discriminator": [ + 149, + 95, + 181, + 242, + 94, + 90, + 158, + 162 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "pool", + "writable": true, + "relations": [ + "position" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "reward_vault", + "docs": [ + "The vault token account for reward token" + ], + "writable": true + }, + { + "name": "reward_mint" + }, + { + "name": "user_token_account", + "writable": true + }, + { + "name": "position_nft_account", + "docs": [ + "The token account for nft" + ] + }, + { + "name": "owner", + "docs": [ + "owner of position" + ], + "signer": true + }, + { + "name": "token_program" + }, + { + "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": "skip_reward", + "type": "u8" + } + ] + }, + { + "name": "close_claim_fee_operator", + "discriminator": [ + 38, + 134, + 82, + 216, + 95, + 124, + 17, + 99 + ], + "accounts": [ + { + "name": "claim_fee_operator", + "writable": true + }, + { + "name": "rent_receiver", + "writable": true + }, + { + "name": "admin", + "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": "close_config", + "discriminator": [ + 145, + 9, + 72, + 157, + 95, + 125, + 61, + 85 + ], + "accounts": [ + { + "name": "config", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "rent_receiver", + "writable": true + }, + { + "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": "close_position", + "discriminator": [ + 123, + 134, + 81, + 0, + 49, + 68, + 98, + 98 + ], + "accounts": [ + { + "name": "position_nft_mint", + "docs": [ + "position_nft_mint" + ], + "writable": true + }, + { + "name": "position_nft_account", + "docs": [ + "The token account for nft" + ], + "writable": true + }, + { + "name": "pool", + "writable": true, + "relations": [ + "position" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "rent_receiver", + "writable": true + }, + { + "name": "owner", + "docs": [ + "Owner of position" + ], + "signer": true + }, + { + "name": "token_program", + "docs": [ + "Program to create NFT mint/token account and transfer for token22 account" + ], + "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + }, + { + "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": "close_token_badge", + "discriminator": [ + 108, + 146, + 86, + 110, + 179, + 254, + 10, + 104 + ], + "accounts": [ + { + "name": "token_badge", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "rent_receiver", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "create_claim_fee_operator", + "discriminator": [ + 169, + 62, + 207, + 107, + 58, + 187, + 162, + 109 + ], + "accounts": [ + { + "name": "claim_fee_operator", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 102, + 95, + 111, + 112, + 101, + 114, + 97, + 116, + 111, + 114 + ] + }, + { + "kind": "account", + "path": "operator" + } + ] + } + }, + { + "name": "operator" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "create_config", + "docs": [ + "ADMIN FUNCTIONS /////" + ], + "discriminator": [ + 201, + 207, + 243, + 114, + 75, + 111, + 47, + 189 + ], + "accounts": [ + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + }, + { + "kind": "arg", + "path": "index" + } + ] + } + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "index", + "type": "u64" + }, + { + "name": "config_parameters", + "type": { + "defined": { + "name": "StaticConfigParameters" + } + } + } + ] + }, + { + "name": "create_dynamic_config", + "discriminator": [ + 81, + 251, + 122, + 78, + 66, + 57, + 208, + 82 + ], + "accounts": [ + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + }, + { + "kind": "arg", + "path": "index" + } + ] + } + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "index", + "type": "u64" + }, + { + "name": "config_parameters", + "type": { + "defined": { + "name": "DynamicConfigParameters" + } + } + } + ] + }, + { + "name": "create_position", + "discriminator": [ + 48, + 215, + 197, + 153, + 96, + 203, + 180, + 133 + ], + "accounts": [ + { + "name": "owner" + }, + { + "name": "position_nft_mint", + "docs": [ + "position_nft_mint" + ], + "writable": true, + "signer": true + }, + { + "name": "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 + ] + }, + { + "kind": "account", + "path": "position_nft_mint" + } + ] + } + }, + { + "name": "pool", + "writable": true + }, + { + "name": "position", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 111, + 115, + 105, + 116, + 105, + 111, + 110 + ] + }, + { + "kind": "account", + "path": "position_nft_mint" + } + ] + } + }, + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "payer", + "docs": [ + "Address paying to create the position. Can be anyone" + ], + "writable": true, + "signer": true + }, + { + "name": "token_program", + "docs": [ + "Program to create NFT mint/token account and transfer for token22 account" + ], + "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "create_token_badge", + "discriminator": [ + 88, + 206, + 0, + 91, + 60, + 175, + 151, + 118 + ], + "accounts": [ + { + "name": "token_badge", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 111, + 107, + 101, + 110, + 95, + 98, + 97, + 100, + 103, + 101 + ] + }, + { + "kind": "account", + "path": "token_mint" + } + ] + } + }, + { + "name": "token_mint" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "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 + }, + { + "name": "token_program" + }, + { + "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": "amount", + "type": "u64" + }, + { + "name": "carry_forward", + "type": "bool" + } + ] + }, + { + "name": "initialize_customizable_pool", + "discriminator": [ + 20, + 161, + 241, + 24, + 189, + 221, + 180, + 2 + ], + "accounts": [ + { + "name": "creator" + }, + { + "name": "position_nft_mint", + "docs": [ + "position_nft_mint" + ], + "writable": true, + "signer": true + }, + { + "name": "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 + ] + }, + { + "kind": "account", + "path": "position_nft_mint" + } + ] + } + }, + { + "name": "payer", + "docs": [ + "Address paying to create the pool. Can be anyone" + ], + "writable": true, + "signer": true + }, + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "pool", + "docs": [ + "Initialize an account to store the pool state" + ], + "writable": true + }, + { + "name": "position", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 111, + 115, + 105, + 116, + 105, + 111, + 110 + ] + }, + { + "kind": "account", + "path": "position_nft_mint" + } + ] + } + }, + { + "name": "token_a_mint", + "docs": [ + "Token a mint" + ] + }, + { + "name": "token_b_mint", + "docs": [ + "Token b mint" + ] + }, + { + "name": "token_a_vault", + "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 + ] + }, + { + "kind": "account", + "path": "token_a_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "token_b_vault", + "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 + ] + }, + { + "kind": "account", + "path": "token_b_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "payer_token_a", + "docs": [ + "payer token a account" + ], + "writable": true + }, + { + "name": "payer_token_b", + "docs": [ + "creator token b account" + ], + "writable": true + }, + { + "name": "token_a_program", + "docs": [ + "Program to create mint account and mint tokens" + ] + }, + { + "name": "token_b_program", + "docs": [ + "Program to create mint account and mint tokens" + ] + }, + { + "name": "token_2022_program", + "docs": [ + "Program to create NFT mint/token account and transfer for token22 account" + ], + "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "InitializeCustomizablePoolParameters" + } + } + } + ] + }, + { + "name": "initialize_pool", + "docs": [ + "USER FUNCTIONS ////" + ], + "discriminator": [ + 95, + 180, + 10, + 172, + 84, + 174, + 232, + 40 + ], + "accounts": [ + { + "name": "creator" + }, + { + "name": "position_nft_mint", + "docs": [ + "position_nft_mint" + ], + "writable": true, + "signer": true + }, + { + "name": "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 + ] + }, + { + "kind": "account", + "path": "position_nft_mint" + } + ] + } + }, + { + "name": "payer", + "docs": [ + "Address paying to create the pool. Can be anyone" + ], + "writable": true, + "signer": true + }, + { + "name": "config", + "docs": [ + "Which config the pool belongs to." + ] + }, + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "pool", + "docs": [ + "Initialize an account to store the pool state" + ], + "writable": true + }, + { + "name": "position", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 111, + 115, + 105, + 116, + 105, + 111, + 110 + ] + }, + { + "kind": "account", + "path": "position_nft_mint" + } + ] + } + }, + { + "name": "token_a_mint", + "docs": [ + "Token a mint" + ] + }, + { + "name": "token_b_mint", + "docs": [ + "Token b mint" + ] + }, + { + "name": "token_a_vault", + "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 + ] + }, + { + "kind": "account", + "path": "token_a_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "token_b_vault", + "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 + ] + }, + { + "kind": "account", + "path": "token_b_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "payer_token_a", + "docs": [ + "payer token a account" + ], + "writable": true + }, + { + "name": "payer_token_b", + "docs": [ + "creator token b account" + ], + "writable": true + }, + { + "name": "token_a_program", + "docs": [ + "Program to create mint account and mint tokens" + ] + }, + { + "name": "token_b_program", + "docs": [ + "Program to create mint account and mint tokens" + ] + }, + { + "name": "token_2022_program", + "docs": [ + "Program to create NFT mint/token account and transfer for token22 account" + ], + "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "InitializePoolParameters" + } + } + } + ] + }, + { + "name": "initialize_pool_with_dynamic_config", + "discriminator": [ + 149, + 82, + 72, + 197, + 253, + 252, + 68, + 15 + ], + "accounts": [ + { + "name": "creator" + }, + { + "name": "position_nft_mint", + "docs": [ + "position_nft_mint" + ], + "writable": true, + "signer": true + }, + { + "name": "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 + ] + }, + { + "kind": "account", + "path": "position_nft_mint" + } + ] + } + }, + { + "name": "payer", + "docs": [ + "Address paying to create the pool. Can be anyone" + ], + "writable": true, + "signer": true + }, + { + "name": "pool_creator_authority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "config", + "docs": [ + "Which config the pool belongs to." + ] + }, + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "pool", + "docs": [ + "Initialize an account to store the pool state" + ], + "writable": true + }, + { + "name": "position", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 111, + 115, + 105, + 116, + 105, + 111, + 110 + ] + }, + { + "kind": "account", + "path": "position_nft_mint" + } + ] + } + }, + { + "name": "token_a_mint", + "docs": [ + "Token a mint" + ] + }, + { + "name": "token_b_mint", + "docs": [ + "Token b mint" + ] + }, + { + "name": "token_a_vault", + "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 + ] + }, + { + "kind": "account", + "path": "token_a_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "token_b_vault", + "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 + ] + }, + { + "kind": "account", + "path": "token_b_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "payer_token_a", + "docs": [ + "payer token a account" + ], + "writable": true + }, + { + "name": "payer_token_b", + "docs": [ + "creator token b account" + ], + "writable": true + }, + { + "name": "token_a_program", + "docs": [ + "Program to create mint account and mint tokens" + ] + }, + { + "name": "token_b_program", + "docs": [ + "Program to create mint account and mint tokens" + ] + }, + { + "name": "token_2022_program", + "docs": [ + "Program to create NFT mint/token account and transfer for token22 account" + ], + "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "InitializeCustomizablePoolParameters" + } + } + } + ] + }, + { + "name": "initialize_reward", + "discriminator": [ + 95, + 135, + 192, + 196, + 242, + 129, + 230, + 68 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "pool", + "writable": true + }, + { + "name": "reward_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 119, + 97, + 114, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "pool" + }, + { + "kind": "arg", + "path": "reward_index" + } + ] + } + }, + { + "name": "reward_mint" + }, + { + "name": "signer", + "signer": true + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "reward_index", + "type": "u8" + }, + { + "name": "reward_duration", + "type": "u64" + }, + { + "name": "funder", + "type": "pubkey" + } + ] + }, + { + "name": "lock_position", + "discriminator": [ + 227, + 62, + 2, + 252, + 247, + 10, + 171, + 185 + ], + "accounts": [ + { + "name": "pool", + "relations": [ + "position" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "vesting", + "writable": true, + "signer": true + }, + { + "name": "position_nft_account", + "docs": [ + "The token account for nft" + ] + }, + { + "name": "owner", + "docs": [ + "owner of position" + ], + "signer": true + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "VestingParameters" + } + } + } + ] + }, + { + "name": "permanent_lock_position", + "discriminator": [ + 165, + 176, + 125, + 6, + 231, + 171, + 186, + 213 + ], + "accounts": [ + { + "name": "pool", + "writable": true, + "relations": [ + "position" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "position_nft_account", + "docs": [ + "The token account for nft" + ] + }, + { + "name": "owner", + "docs": [ + "owner of position" + ], + "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": "permanent_lock_liquidity", + "type": "u128" + } + ] + }, + { + "name": "refresh_vesting", + "discriminator": [ + 9, + 94, + 216, + 14, + 116, + 204, + 247, + 0 + ], + "accounts": [ + { + "name": "pool", + "relations": [ + "position" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "position_nft_account", + "docs": [ + "The token account for nft" + ] + }, + { + "name": "owner" + } + ], + "args": [] + }, + { + "name": "remove_all_liquidity", + "discriminator": [ + 10, + 51, + 61, + 35, + 112, + 105, + 24, + 85 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "pool", + "writable": true, + "relations": [ + "position" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "token_a_account", + "docs": [ + "The user token a account" + ], + "writable": true + }, + { + "name": "token_b_account", + "docs": [ + "The user token b account" + ], + "writable": true + }, + { + "name": "token_a_vault", + "docs": [ + "The vault token account for input token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_b_vault", + "docs": [ + "The vault token account for output token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_a_mint", + "docs": [ + "The mint of token a" + ], + "relations": [ + "pool" + ] + }, + { + "name": "token_b_mint", + "docs": [ + "The mint of token b" + ], + "relations": [ + "pool" + ] + }, + { + "name": "position_nft_account", + "docs": [ + "The token account for nft" + ] + }, + { + "name": "owner", + "docs": [ + "owner of position" + ], + "signer": true + }, + { + "name": "token_a_program", + "docs": [ + "Token a program" + ] + }, + { + "name": "token_b_program", + "docs": [ + "Token b program" + ] + }, + { + "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": "token_a_amount_threshold", + "type": "u64" + }, + { + "name": "token_b_amount_threshold", + "type": "u64" + } + ] + }, + { + "name": "remove_liquidity", + "discriminator": [ + 80, + 85, + 209, + 72, + 24, + 206, + 177, + 108 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "pool", + "writable": true, + "relations": [ + "position" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "token_a_account", + "docs": [ + "The user token a account" + ], + "writable": true + }, + { + "name": "token_b_account", + "docs": [ + "The user token b account" + ], + "writable": true + }, + { + "name": "token_a_vault", + "docs": [ + "The vault token account for input token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_b_vault", + "docs": [ + "The vault token account for output token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_a_mint", + "docs": [ + "The mint of token a" + ], + "relations": [ + "pool" + ] + }, + { + "name": "token_b_mint", + "docs": [ + "The mint of token b" + ], + "relations": [ + "pool" + ] + }, + { + "name": "position_nft_account", + "docs": [ + "The token account for nft" + ] + }, + { + "name": "owner", + "docs": [ + "owner of position" + ], + "signer": true + }, + { + "name": "token_a_program", + "docs": [ + "Token a program" + ] + }, + { + "name": "token_b_program", + "docs": [ + "Token b program" + ] + }, + { + "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": "params", + "type": { + "defined": { + "name": "RemoveLiquidityParameters" + } + } + } + ] + }, + { + "name": "set_pool_status", + "discriminator": [ + 112, + 87, + 135, + 223, + 83, + 204, + 132, + 53 + ], + "accounts": [ + { + "name": "pool", + "writable": true + }, + { + "name": "admin", + "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": "status", + "type": "u8" + } + ] + }, + { + "name": "split_position", + "discriminator": [ + 172, + 241, + 221, + 138, + 161, + 29, + 253, + 42 + ], + "accounts": [ + { + "name": "pool", + "writable": true, + "relations": [ + "first_position", + "second_position" + ] + }, + { + "name": "first_position", + "docs": [ + "The first position" + ], + "writable": true + }, + { + "name": "first_position_nft_account", + "docs": [ + "The token account for position nft" + ] + }, + { + "name": "second_position", + "docs": [ + "The second position" + ], + "writable": true + }, + { + "name": "second_position_nft_account", + "docs": [ + "The token account for position nft" + ] + }, + { + "name": "first_owner", + "docs": [ + "Owner of first position" + ], + "signer": true + }, + { + "name": "second_owner", + "docs": [ + "Owner of second position" + ], + "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": "params", + "type": { + "defined": { + "name": "SplitPositionParameters" + } + } + } + ] + }, + { + "name": "swap", + "discriminator": [ + 248, + 198, + 158, + 145, + 225, + 117, + 135, + 200 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC" + }, + { + "name": "pool", + "docs": [ + "Pool account" + ], + "writable": true + }, + { + "name": "input_token_account", + "docs": [ + "The user token account for input token" + ], + "writable": true + }, + { + "name": "output_token_account", + "docs": [ + "The user token account for output token" + ], + "writable": true + }, + { + "name": "token_a_vault", + "docs": [ + "The vault token account for input token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_b_vault", + "docs": [ + "The vault token account for output token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_a_mint", + "docs": [ + "The mint of token a" + ] + }, + { + "name": "token_b_mint", + "docs": [ + "The mint of token b" + ] + }, + { + "name": "payer", + "docs": [ + "The user performing the swap" + ], + "signer": true + }, + { + "name": "token_a_program", + "docs": [ + "Token a program" + ] + }, + { + "name": "token_b_program", + "docs": [ + "Token b program" + ] + }, + { + "name": "referral_token_account", + "docs": [ + "referral token account" + ], + "writable": true, + "optional": 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": "params", + "type": { + "defined": { + "name": "SwapParameters" + } + } + } + ] + }, + { + "name": "update_reward_duration", + "discriminator": [ + 138, + 174, + 196, + 169, + 213, + 235, + 254, + 107 + ], + "accounts": [ + { + "name": "pool", + "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_duration", + "type": "u64" + } + ] + }, + { + "name": "update_reward_funder", + "discriminator": [ + 211, + 28, + 48, + 32, + 215, + 160, + 35, + 23 + ], + "accounts": [ + { + "name": "pool", + "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" + }, + { + "name": "funder_token_account", + "writable": true + }, + { + "name": "funder", + "signer": true + }, + { + "name": "token_program" + }, + { + "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" + } + ] + } + ], + "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": "EvtClaimPositionFee", + "discriminator": [ + 198, + 182, + 183, + 52, + 97, + 12, + 49, + 56 + ] + }, + { + "name": "EvtClaimProtocolFee", + "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 + ] + }, + { + "name": "EvtCloseConfig", + "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 + ] + }, + { + "name": "EvtCreateConfig", + "discriminator": [ + 131, + 207, + 180, + 174, + 180, + 73, + 165, + 54 + ] + }, + { + "name": "EvtCreateDynamicConfig", + "discriminator": [ + 231, + 197, + 13, + 164, + 248, + 213, + 133, + 152 + ] + }, + { + "name": "EvtCreatePosition", + "discriminator": [ + 156, + 15, + 119, + 198, + 29, + 181, + 221, + 55 + ] + }, + { + "name": "EvtCreateTokenBadge", + "discriminator": [ + 141, + 120, + 134, + 116, + 34, + 28, + 114, + 160 + ] + }, + { + "name": "EvtFundReward", + "discriminator": [ + 104, + 233, + 237, + 122, + 199, + 191, + 121, + 85 + ] + }, + { + "name": "EvtInitializePool", + "discriminator": [ + 228, + 50, + 246, + 85, + 203, + 66, + 134, + 37 + ] + }, + { + "name": "EvtInitializeReward", + "discriminator": [ + 129, + 91, + 188, + 3, + 246, + 52, + 185, + 249 + ] + }, + { + "name": "EvtLockPosition", + "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 + ] + }, + { + "name": "EvtSetPoolStatus", + "discriminator": [ + 100, + 213, + 74, + 3, + 95, + 91, + 228, + 146 + ] + }, + { + "name": "EvtSplitPosition", + "discriminator": [ + 182, + 138, + 42, + 254, + 27, + 94, + 82, + 221 + ] + }, + { + "name": "EvtSwap", + "discriminator": [ + 27, + 60, + 21, + 213, + 138, + 170, + 187, + 147 + ] + }, + { + "name": "EvtUpdateRewardDuration", + "discriminator": [ + 149, + 135, + 65, + 231, + 129, + 153, + 65, + 57 + ] + }, + { + "name": "EvtUpdateRewardFunder", + "discriminator": [ + 76, + 154, + 208, + 13, + 40, + 115, + 246, + 146 + ] + }, + { + "name": "EvtWithdrawIneligibleReward", + "discriminator": [ + 248, + 215, + 184, + 78, + 31, + 180, + 179, + 168 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "MathOverflow", + "msg": "Math operation overflow" + }, + { + "code": 6001, + "name": "InvalidFee", + "msg": "Invalid fee setup" + }, + { + "code": 6002, + "name": "ExceededSlippage", + "msg": "Exceeded slippage tolerance" + }, + { + "code": 6003, + "name": "PoolDisabled", + "msg": "Pool disabled" + }, + { + "code": 6004, + "name": "ExceedMaxFeeBps", + "msg": "Exceeded max fee bps" + }, + { + "code": 6005, + "name": "InvalidAdmin", + "msg": "Invalid admin" + }, + { + "code": 6006, + "name": "AmountIsZero", + "msg": "Amount is zero" + }, + { + "code": 6007, + "name": "TypeCastFailed", + "msg": "Type cast error" + }, + { + "code": 6008, + "name": "UnableToModifyActivationPoint", + "msg": "Unable to modify activation point" + }, + { + "code": 6009, + "name": "InvalidAuthorityToCreateThePool", + "msg": "Invalid authority to create the pool" + }, + { + "code": 6010, + "name": "InvalidActivationType", + "msg": "Invalid activation type" + }, + { + "code": 6011, + "name": "InvalidActivationPoint", + "msg": "Invalid activation point" + }, + { + "code": 6012, + "name": "InvalidQuoteMint", + "msg": "Quote token must be SOL,USDC" + }, + { + "code": 6013, + "name": "InvalidFeeCurve", + "msg": "Invalid fee curve" + }, + { + "code": 6014, + "name": "InvalidPriceRange", + "msg": "Invalid Price Range" + }, + { + "code": 6015, + "name": "PriceRangeViolation", + "msg": "Trade is over price range" + }, + { + "code": 6016, + "name": "InvalidParameters", + "msg": "Invalid parameters" + }, + { + "code": 6017, + "name": "InvalidCollectFeeMode", + "msg": "Invalid collect fee mode" + }, + { + "code": 6018, + "name": "InvalidInput", + "msg": "Invalid input" + }, + { + "code": 6019, + "name": "CannotCreateTokenBadgeOnSupportedMint", + "msg": "Cannot create token badge on supported mint" + }, + { + "code": 6020, + "name": "InvalidTokenBadge", + "msg": "Invalid token badge" + }, + { + "code": 6021, + "name": "InvalidMinimumLiquidity", + "msg": "Invalid minimum liquidity" + }, + { + "code": 6022, + "name": "InvalidVestingInfo", + "msg": "Invalid vesting information" + }, + { + "code": 6023, + "name": "InsufficientLiquidity", + "msg": "Insufficient liquidity" + }, + { + "code": 6024, + "name": "InvalidVestingAccount", + "msg": "Invalid vesting account" + }, + { + "code": 6025, + "name": "InvalidPoolStatus", + "msg": "Invalid pool status" + }, + { + "code": 6026, + "name": "UnsupportNativeMintToken2022", + "msg": "Unsupported native mint token2022" + }, + { + "code": 6027, + "name": "InvalidRewardIndex", + "msg": "Invalid reward index" + }, + { + "code": 6028, + "name": "InvalidRewardDuration", + "msg": "Invalid reward duration" + }, + { + "code": 6029, + "name": "RewardInitialized", + "msg": "Reward already initialized" + }, + { + "code": 6030, + "name": "RewardUninitialized", + "msg": "Reward not initialized" + }, + { + "code": 6031, + "name": "InvalidRewardVault", + "msg": "Invalid reward vault" + }, + { + "code": 6032, + "name": "MustWithdrawnIneligibleReward", + "msg": "Must withdraw ineligible reward" + }, + { + "code": 6033, + "name": "IdenticalRewardDuration", + "msg": "Reward duration is the same" + }, + { + "code": 6034, + "name": "RewardCampaignInProgress", + "msg": "Reward campaign in progress" + }, + { + "code": 6035, + "name": "IdenticalFunder", + "msg": "Identical funder" + }, + { + "code": 6036, + "name": "InvalidFunder", + "msg": "Invalid funder" + }, + { + "code": 6037, + "name": "RewardNotEnded", + "msg": "Reward not ended" + }, + { + "code": 6038, + "name": "FeeInverseIsIncorrect", + "msg": "Fee inverse is incorrect" + }, + { + "code": 6039, + "name": "PositionIsNotEmpty", + "msg": "Position is not empty" + }, + { + "code": 6040, + "name": "InvalidPoolCreatorAuthority", + "msg": "Invalid pool creator authority" + }, + { + "code": 6041, + "name": "InvalidConfigType", + "msg": "Invalid config type" + }, + { + "code": 6042, + "name": "InvalidPoolCreator", + "msg": "Invalid pool creator" + }, + { + "code": 6043, + "name": "RewardVaultFrozenSkipRequired", + "msg": "Reward vault is frozen, must skip reward to proceed" + }, + { + "code": 6044, + "name": "InvalidSplitPositionParameters", + "msg": "Invalid parameters for split position" + }, + { + "code": 6045, + "name": "UnsupportPositionHasVestingLock", + "msg": "Unsupported split position has vesting lock" + }, + { + "code": 6046, + "name": "SamePosition", + "msg": "Same position" + } + ], + "types": [ + { + "name": "AddLiquidityParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "liquidity_delta", + "docs": [ + "delta liquidity" + ], + "type": "u128" + }, + { + "name": "token_a_amount_threshold", + "docs": [ + "maximum token a amount" + ], + "type": "u64" + }, + { + "name": "token_b_amount_threshold", + "docs": [ + "maximum token b amount" + ], + "type": "u64" + } + ] + } + }, + { + "name": "BaseFeeConfig", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "cliff_fee_numerator", + "type": "u64" + }, + { + "name": "fee_scheduler_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": "BaseFeeParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "cliff_fee_numerator", + "type": "u64" + }, + { + "name": "number_of_period", + "type": "u16" + }, + { + "name": "period_frequency", + "type": "u64" + }, + { + "name": "reduction_factor", + "type": "u64" + }, + { + "name": "fee_scheduler_mode", + "type": "u8" + } + ] + } + }, + { + "name": "BaseFeeStruct", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "cliff_fee_numerator", + "type": "u64" + }, + { + "name": "fee_scheduler_mode", + "type": "u8" + }, + { + "name": "padding_0", + "type": { + "array": [ + "u8", + 5 + ] + } + }, + { + "name": "number_of_period", + "type": "u16" + }, + { + "name": "period_frequency", + "type": "u64" + }, + { + "name": "reduction_factor", + "type": "u64" + }, + { + "name": "padding_1", + "type": "u64" + } + ] + } + }, + { + "name": "ClaimFeeOperator", + "docs": [ + "Parameter that set by the protocol" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "operator", + "docs": [ + "operator" + ], + "type": "pubkey" + }, + { + "name": "_padding", + "docs": [ + "Reserve" + ], + "type": { + "array": [ + "u8", + 128 + ] + } + } + ] + } + }, + { + "name": "Config", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "vault_config_key", + "docs": [ + "Vault config key" + ], + "type": "pubkey" + }, + { + "name": "pool_creator_authority", + "docs": [ + "Only pool_creator_authority can use the current config to initialize new pool. When it's Pubkey::default, it's a public config." + ], + "type": "pubkey" + }, + { + "name": "pool_fees", + "docs": [ + "Pool fee" + ], + "type": { + "defined": { + "name": "PoolFeesConfig" + } + } + }, + { + "name": "activation_type", + "docs": [ + "Activation type" + ], + "type": "u8" + }, + { + "name": "collect_fee_mode", + "docs": [ + "Collect fee mode" + ], + "type": "u8" + }, + { + "name": "config_type", + "docs": [ + "Config type mode, 0 for static, 1 for dynamic" + ], + "type": "u8" + }, + { + "name": "_padding_0", + "docs": [ + "padding 0" + ], + "type": { + "array": [ + "u8", + 5 + ] + } + }, + { + "name": "index", + "docs": [ + "config index" + ], + "type": "u64" + }, + { + "name": "sqrt_min_price", + "docs": [ + "sqrt min price" + ], + "type": "u128" + }, + { + "name": "sqrt_max_price", + "docs": [ + "sqrt max price" + ], + "type": "u128" + }, + { + "name": "_padding_1", + "docs": [ + "Fee curve point", + "Padding for further use" + ], + "type": { + "array": [ + "u64", + 10 + ] + } + } + ] + } + }, + { + "name": "DynamicConfigParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool_creator_authority", + "type": "pubkey" + } + ] + } + }, + { + "name": "DynamicFeeConfig", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "initialized", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 7 + ] + } + }, + { + "name": "max_volatility_accumulator", + "type": "u32" + }, + { + "name": "variable_fee_control", + "type": "u32" + }, + { + "name": "bin_step", + "type": "u16" + }, + { + "name": "filter_period", + "type": "u16" + }, + { + "name": "decay_period", + "type": "u16" + }, + { + "name": "reduction_factor", + "type": "u16" + }, + { + "name": "padding_1", + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "bin_step_u128", + "type": "u128" + } + ] + } + }, + { + "name": "DynamicFeeParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bin_step", + "type": "u16" + }, + { + "name": "bin_step_u128", + "type": "u128" + }, + { + "name": "filter_period", + "type": "u16" + }, + { + "name": "decay_period", + "type": "u16" + }, + { + "name": "reduction_factor", + "type": "u16" + }, + { + "name": "max_volatility_accumulator", + "type": "u32" + }, + { + "name": "variable_fee_control", + "type": "u32" + } + ] + } + }, + { + "name": "DynamicFeeStruct", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "initialized", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 7 + ] + } + }, + { + "name": "max_volatility_accumulator", + "type": "u32" + }, + { + "name": "variable_fee_control", + "type": "u32" + }, + { + "name": "bin_step", + "type": "u16" + }, + { + "name": "filter_period", + "type": "u16" + }, + { + "name": "decay_period", + "type": "u16" + }, + { + "name": "reduction_factor", + "type": "u16" + }, + { + "name": "last_update_timestamp", + "type": "u64" + }, + { + "name": "bin_step_u128", + "type": "u128" + }, + { + "name": "sqrt_price_reference", + "type": "u128" + }, + { + "name": "volatility_accumulator", + "type": "u128" + }, + { + "name": "volatility_reference", + "type": "u128" + } + ] + } + }, + { + "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": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "token_a_amount", + "type": "u64" + }, + { + "name": "token_b_amount", + "type": "u64" + } + ] + } + }, + { + "name": "EvtClaimPositionFee", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "position", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "fee_a_claimed", + "type": "u64" + }, + { + "name": "fee_b_claimed", + "type": "u64" + } + ] + } + }, + { + "name": "EvtClaimProtocolFee", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "token_a_amount", + "type": "u64" + }, + { + "name": "token_b_amount", + "type": "u64" + } + ] + } + }, + { + "name": "EvtClaimReward", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "position", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "mint_reward", + "type": "pubkey" + }, + { + "name": "reward_index", + "type": "u8" + }, + { + "name": "total_reward", + "type": "u64" + } + ] + } + }, + { + "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" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "config", + "docs": [ + "Config pubkey" + ], + "type": "pubkey" + }, + { + "name": "admin", + "docs": [ + "admin pk" + ], + "type": "pubkey" + } + ] + } + }, + { + "name": "EvtClosePosition", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "position", + "type": "pubkey" + }, + { + "name": "position_nft_mint", + "type": "pubkey" + } + ] + } + }, + { + "name": "EvtCreateClaimFeeOperator", + "docs": [ + "Create claim fee operator" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "operator", + "type": "pubkey" + } + ] + } + }, + { + "name": "EvtCreateConfig", + "docs": [ + "Create static config" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool_fees", + "type": { + "defined": { + "name": "PoolFeeParameters" + } + } + }, + { + "name": "vault_config_key", + "type": "pubkey" + }, + { + "name": "pool_creator_authority", + "type": "pubkey" + }, + { + "name": "activation_type", + "type": "u8" + }, + { + "name": "sqrt_min_price", + "type": "u128" + }, + { + "name": "sqrt_max_price", + "type": "u128" + }, + { + "name": "collect_fee_mode", + "type": "u8" + }, + { + "name": "index", + "type": "u64" + }, + { + "name": "config", + "type": "pubkey" + } + ] + } + }, + { + "name": "EvtCreateDynamicConfig", + "docs": [ + "Create dynamic config" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "config", + "type": "pubkey" + }, + { + "name": "pool_creator_authority", + "type": "pubkey" + }, + { + "name": "index", + "type": "u64" + } + ] + } + }, + { + "name": "EvtCreatePosition", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "position", + "type": "pubkey" + }, + { + "name": "position_nft_mint", + "type": "pubkey" + } + ] + } + }, + { + "name": "EvtCreateTokenBadge", + "docs": [ + "Create token badge" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "token_mint", + "type": "pubkey" + } + ] + } + }, + { + "name": "EvtFundReward", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "funder", + "type": "pubkey" + }, + { + "name": "mint_reward", + "type": "pubkey" + }, + { + "name": "reward_index", + "type": "u8" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "transfer_fee_excluded_amount_in", + "type": "u64" + }, + { + "name": "reward_duration_end", + "type": "u64" + }, + { + "name": "pre_reward_rate", + "type": "u128" + }, + { + "name": "post_reward_rate", + "type": "u128" + } + ] + } + }, + { + "name": "EvtInitializePool", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "token_a_mint", + "type": "pubkey" + }, + { + "name": "token_b_mint", + "type": "pubkey" + }, + { + "name": "creator", + "type": "pubkey" + }, + { + "name": "payer", + "type": "pubkey" + }, + { + "name": "alpha_vault", + "type": "pubkey" + }, + { + "name": "pool_fees", + "type": { + "defined": { + "name": "PoolFeeParameters" + } + } + }, + { + "name": "sqrt_min_price", + "type": "u128" + }, + { + "name": "sqrt_max_price", + "type": "u128" + }, + { + "name": "activation_type", + "type": "u8" + }, + { + "name": "collect_fee_mode", + "type": "u8" + }, + { + "name": "liquidity", + "type": "u128" + }, + { + "name": "sqrt_price", + "type": "u128" + }, + { + "name": "activation_point", + "type": "u64" + }, + { + "name": "token_a_flag", + "type": "u8" + }, + { + "name": "token_b_flag", + "type": "u8" + }, + { + "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": "pool_type", + "type": "u8" + } + ] + } + }, + { + "name": "EvtInitializeReward", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "reward_mint", + "type": "pubkey" + }, + { + "name": "funder", + "type": "pubkey" + }, + { + "name": "creator", + "type": "pubkey" + }, + { + "name": "reward_index", + "type": "u8" + }, + { + "name": "reward_duration", + "type": "u64" + } + ] + } + }, + { + "name": "EvtLockPosition", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "position", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "vesting", + "type": "pubkey" + }, + { + "name": "cliff_point", + "type": "u64" + }, + { + "name": "period_frequency", + "type": "u64" + }, + { + "name": "cliff_unlock_liquidity", + "type": "u128" + }, + { + "name": "liquidity_per_period", + "type": "u128" + }, + { + "name": "number_of_period", + "type": "u16" + } + ] + } + }, + { + "name": "EvtPermanentLockPosition", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "position", + "type": "pubkey" + }, + { + "name": "lock_liquidity_amount", + "type": "u128" + }, + { + "name": "total_permanent_locked_liquidity", + "type": "u128" + } + ] + } + }, + { + "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": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "status", + "type": "u8" + } + ] + } + }, + { + "name": "EvtSplitPosition", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "first_owner", + "type": "pubkey" + }, + { + "name": "second_owner", + "type": "pubkey" + }, + { + "name": "first_position", + "type": "pubkey" + }, + { + "name": "second_position", + "type": "pubkey" + }, + { + "name": "current_sqrt_price", + "type": "u128" + }, + { + "name": "amount_splits", + "type": { + "defined": { + "name": "SplitAmountInfo" + } + } + }, + { + "name": "first_position_info", + "type": { + "defined": { + "name": "SplitPositionInfo" + } + } + }, + { + "name": "second_position_info", + "type": { + "defined": { + "name": "SplitPositionInfo" + } + } + }, + { + "name": "split_position_parameters", + "type": { + "defined": { + "name": "SplitPositionParameters" + } + } + } + ] + } + }, + { + "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": "EvtUpdateRewardDuration", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "reward_index", + "type": "u8" + }, + { + "name": "old_reward_duration", + "type": "u64" + }, + { + "name": "new_reward_duration", + "type": "u64" + } + ] + } + }, + { + "name": "EvtUpdateRewardFunder", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "reward_index", + "type": "u8" + }, + { + "name": "old_funder", + "type": "pubkey" + }, + { + "name": "new_funder", + "type": "pubkey" + } + ] + } + }, + { + "name": "EvtWithdrawIneligibleReward", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "reward_mint", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "InitializeCustomizablePoolParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool_fees", + "docs": [ + "pool fees" + ], + "type": { + "defined": { + "name": "PoolFeeParameters" + } + } + }, + { + "name": "sqrt_min_price", + "docs": [ + "sqrt min price" + ], + "type": "u128" + }, + { + "name": "sqrt_max_price", + "docs": [ + "sqrt max price" + ], + "type": "u128" + }, + { + "name": "has_alpha_vault", + "docs": [ + "has alpha vault" + ], + "type": "bool" + }, + { + "name": "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" + ], + "type": "u128" + }, + { + "name": "activation_type", + "docs": [ + "activation type" + ], + "type": "u8" + }, + { + "name": "collect_fee_mode", + "docs": [ + "collect fee mode" + ], + "type": "u8" + }, + { + "name": "activation_point", + "docs": [ + "activation point" + ], + "type": { + "option": "u64" + } + } + ] + } + }, + { + "name": "InitializePoolParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "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" + ], + "type": "u128" + }, + { + "name": "activation_point", + "docs": [ + "activation point" + ], + "type": { + "option": "u64" + } + } + ] + } + }, + { + "name": "Pool", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool_fees", + "docs": [ + "Pool fee" + ], + "type": { + "defined": { + "name": "PoolFeesStruct" + } + } + }, + { + "name": "token_a_mint", + "docs": [ + "token a mint" + ], + "type": "pubkey" + }, + { + "name": "token_b_mint", + "docs": [ + "token b mint" + ], + "type": "pubkey" + }, + { + "name": "token_a_vault", + "docs": [ + "token a vault" + ], + "type": "pubkey" + }, + { + "name": "token_b_vault", + "docs": [ + "token b vault" + ], + "type": "pubkey" + }, + { + "name": "whitelisted_vault", + "docs": [ + "Whitelisted vault to be able to buy pool before activation_point" + ], + "type": "pubkey" + }, + { + "name": "partner", + "docs": [ + "partner" + ], + "type": "pubkey" + }, + { + "name": "liquidity", + "docs": [ + "liquidity share" + ], + "type": "u128" + }, + { + "name": "_padding", + "docs": [ + "padding, previous reserve amount, be careful to use that field" + ], + "type": "u128" + }, + { + "name": "protocol_a_fee", + "docs": [ + "protocol a fee" + ], + "type": "u64" + }, + { + "name": "protocol_b_fee", + "docs": [ + "protocol b fee" + ], + "type": "u64" + }, + { + "name": "partner_a_fee", + "docs": [ + "partner a fee" + ], + "type": "u64" + }, + { + "name": "partner_b_fee", + "docs": [ + "partner b fee" + ], + "type": "u64" + }, + { + "name": "sqrt_min_price", + "docs": [ + "min price" + ], + "type": "u128" + }, + { + "name": "sqrt_max_price", + "docs": [ + "max price" + ], + "type": "u128" + }, + { + "name": "sqrt_price", + "docs": [ + "current price" + ], + "type": "u128" + }, + { + "name": "activation_point", + "docs": [ + "Activation point, can be slot or timestamp" + ], + "type": "u64" + }, + { + "name": "activation_type", + "docs": [ + "Activation type, 0 means by slot, 1 means by timestamp" + ], + "type": "u8" + }, + { + "name": "pool_status", + "docs": [ + "pool status, 0: enable, 1 disable" + ], + "type": "u8" + }, + { + "name": "token_a_flag", + "docs": [ + "token a flag" + ], + "type": "u8" + }, + { + "name": "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" + ], + "type": "u8" + }, + { + "name": "pool_type", + "docs": [ + "pool type" + ], + "type": "u8" + }, + { + "name": "_padding_0", + "docs": [ + "padding" + ], + "type": { + "array": [ + "u8", + 2 + ] + } + }, + { + "name": "fee_a_per_liquidity", + "docs": [ + "cumulative" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "fee_b_per_liquidity", + "docs": [ + "cumulative" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "permanent_lock_liquidity", + "type": "u128" + }, + { + "name": "metrics", + "docs": [ + "metrics" + ], + "type": { + "defined": { + "name": "PoolMetrics" + } + } + }, + { + "name": "creator", + "docs": [ + "pool creator" + ], + "type": "pubkey" + }, + { + "name": "_padding_1", + "docs": [ + "Padding for further use" + ], + "type": { + "array": [ + "u64", + 6 + ] + } + }, + { + "name": "reward_infos", + "docs": [ + "Farming reward information" + ], + "type": { + "array": [ + { + "defined": { + "name": "RewardInfo" + } + }, + 2 + ] + } + } + ] + } + }, + { + "name": "PoolFeeParameters", + "docs": [ + "Information regarding fee charges" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "base_fee", + "docs": [ + "Base fee" + ], + "type": { + "defined": { + "name": "BaseFeeParameters" + } + } + }, + { + "name": "padding", + "docs": [ + "padding" + ], + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "dynamic_fee", + "docs": [ + "dynamic fee" + ], + "type": { + "option": { + "defined": { + "name": "DynamicFeeParameters" + } + } + } + } + ] + } + }, + { + "name": "PoolFeesConfig", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "base_fee", + "type": { + "defined": { + "name": "BaseFeeConfig" + } + } + }, + { + "name": "dynamic_fee", + "type": { + "defined": { + "name": "DynamicFeeConfig" + } + } + }, + { + "name": "protocol_fee_percent", + "type": "u8" + }, + { + "name": "partner_fee_percent", + "type": "u8" + }, + { + "name": "referral_fee_percent", + "type": "u8" + }, + { + "name": "padding_0", + "type": { + "array": [ + "u8", + 5 + ] + } + }, + { + "name": "padding_1", + "type": { + "array": [ + "u64", + 5 + ] + } + } + ] + } + }, + { + "name": "PoolFeesStruct", + "docs": [ + "Information regarding fee charges", + "trading_fee = amount * trade_fee_numerator / denominator", + "protocol_fee = trading_fee * protocol_fee_percentage / 100", + "referral_fee = protocol_fee * referral_percentage / 100", + "partner_fee = (protocol_fee - referral_fee) * partner_fee_percentage / denominator" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "base_fee", + "docs": [ + "Trade fees are extra token amounts that are held inside the token", + "accounts during a trade, making the value of liquidity tokens rise.", + "Trade fee numerator" + ], + "type": { + "defined": { + "name": "BaseFeeStruct" + } + } + }, + { + "name": "protocol_fee_percent", + "docs": [ + "Protocol trading fees are extra token amounts that are held inside the token", + "accounts during a trade, with the equivalent in pool tokens minted to", + "the protocol of the program.", + "Protocol trade fee numerator" + ], + "type": "u8" + }, + { + "name": "partner_fee_percent", + "docs": [ + "partner fee" + ], + "type": "u8" + }, + { + "name": "referral_fee_percent", + "docs": [ + "referral fee" + ], + "type": "u8" + }, + { + "name": "padding_0", + "docs": [ + "padding" + ], + "type": { + "array": [ + "u8", + 5 + ] + } + }, + { + "name": "dynamic_fee", + "docs": [ + "dynamic fee" + ], + "type": { + "defined": { + "name": "DynamicFeeStruct" + } + } + }, + { + "name": "padding_1", + "docs": [ + "padding" + ], + "type": { + "array": [ + "u64", + 2 + ] + } + } + ] + } + }, + { + "name": "PoolMetrics", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "total_lp_a_fee", + "type": "u128" + }, + { + "name": "total_lp_b_fee", + "type": "u128" + }, + { + "name": "total_protocol_a_fee", + "type": "u64" + }, + { + "name": "total_protocol_b_fee", + "type": "u64" + }, + { + "name": "total_partner_a_fee", + "type": "u64" + }, + { + "name": "total_partner_b_fee", + "type": "u64" + }, + { + "name": "total_position", + "type": "u64" + }, + { + "name": "padding", + "type": "u64" + } + ] + } + }, + { + "name": "Position", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "nft_mint", + "docs": [ + "nft mint" + ], + "type": "pubkey" + }, + { + "name": "fee_a_per_token_checkpoint", + "docs": [ + "fee a checkpoint" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "fee_b_per_token_checkpoint", + "docs": [ + "fee b checkpoint" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "fee_a_pending", + "docs": [ + "fee a pending" + ], + "type": "u64" + }, + { + "name": "fee_b_pending", + "docs": [ + "fee b pending" + ], + "type": "u64" + }, + { + "name": "unlocked_liquidity", + "docs": [ + "unlock liquidity" + ], + "type": "u128" + }, + { + "name": "vested_liquidity", + "docs": [ + "vesting liquidity" + ], + "type": "u128" + }, + { + "name": "permanent_locked_liquidity", + "docs": [ + "permanent locked liquidity" + ], + "type": "u128" + }, + { + "name": "metrics", + "docs": [ + "metrics" + ], + "type": { + "defined": { + "name": "PositionMetrics" + } + } + }, + { + "name": "reward_infos", + "docs": [ + "Farming reward information" + ], + "type": { + "array": [ + { + "defined": { + "name": "UserRewardInfo" + } + }, + 2 + ] + } + }, + { + "name": "padding", + "docs": [ + "padding for future usage" + ], + "type": { + "array": [ + "u128", + 6 + ] + } + } + ] + } + }, + { + "name": "PositionMetrics", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "total_claimed_a_fee", + "type": "u64" + }, + { + "name": "total_claimed_b_fee", + "type": "u64" + } + ] + } + }, + { + "name": "RemoveLiquidityParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "liquidity_delta", + "docs": [ + "delta liquidity" + ], + "type": "u128" + }, + { + "name": "token_a_amount_threshold", + "docs": [ + "minimum token a amount" + ], + "type": "u64" + }, + { + "name": "token_b_amount_threshold", + "docs": [ + "minimum token b amount" + ], + "type": "u64" + } + ] + } + }, + { + "name": "RewardInfo", + "docs": [ + "Stores the state relevant for tracking liquidity mining rewards" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "initialized", + "docs": [ + "Indicates if the reward has been initialized" + ], + "type": "u8" + }, + { + "name": "reward_token_flag", + "docs": [ + "reward token flag" + ], + "type": "u8" + }, + { + "name": "_padding_0", + "docs": [ + "padding" + ], + "type": { + "array": [ + "u8", + 6 + ] + } + }, + { + "name": "_padding_1", + "docs": [ + "Padding to ensure `reward_rate: u128` is 16-byte aligned" + ], + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "mint", + "docs": [ + "Reward token mint." + ], + "type": "pubkey" + }, + { + "name": "vault", + "docs": [ + "Reward vault token account." + ], + "type": "pubkey" + }, + { + "name": "funder", + "docs": [ + "Authority account that allows to fund rewards" + ], + "type": "pubkey" + }, + { + "name": "reward_duration", + "docs": [ + "reward duration" + ], + "type": "u64" + }, + { + "name": "reward_duration_end", + "docs": [ + "reward duration end" + ], + "type": "u64" + }, + { + "name": "reward_rate", + "docs": [ + "reward rate" + ], + "type": "u128" + }, + { + "name": "reward_per_token_stored", + "docs": [ + "Reward per token stored" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "last_update_time", + "docs": [ + "The last time reward states were updated." + ], + "type": "u64" + }, + { + "name": "cumulative_seconds_with_empty_liquidity_reward", + "docs": [ + "Accumulated seconds when the farm distributed rewards but the bin was empty.", + "These rewards will be carried over to the next reward time window." + ], + "type": "u64" + } + ] + } + }, + { + "name": "SplitAmountInfo", + "type": { + "kind": "struct", + "fields": [ + { + "name": "permanent_locked_liquidity", + "type": "u128" + }, + { + "name": "unlocked_liquidity", + "type": "u128" + }, + { + "name": "fee_a", + "type": "u64" + }, + { + "name": "fee_b", + "type": "u64" + }, + { + "name": "reward_0", + "type": "u64" + }, + { + "name": "reward_1", + "type": "u64" + } + ] + } + }, + { + "name": "SplitPositionInfo", + "type": { + "kind": "struct", + "fields": [ + { + "name": "liquidity", + "type": "u128" + }, + { + "name": "fee_a", + "type": "u64" + }, + { + "name": "fee_b", + "type": "u64" + }, + { + "name": "reward_0", + "type": "u64" + }, + { + "name": "reward_1", + "type": "u64" + } + ] + } + }, + { + "name": "SplitPositionParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "unlocked_liquidity_percentage", + "docs": [ + "Percentage of unlocked liquidity to split to the second position" + ], + "type": "u8" + }, + { + "name": "permanent_locked_liquidity_percentage", + "docs": [ + "Percentage of permanent locked liquidity to split to the second position" + ], + "type": "u8" + }, + { + "name": "fee_a_percentage", + "docs": [ + "Percentage of fee A pending to split to the second position" + ], + "type": "u8" + }, + { + "name": "fee_b_percentage", + "docs": [ + "Percentage of fee B pending to split to the second position" + ], + "type": "u8" + }, + { + "name": "reward_0_percentage", + "docs": [ + "Percentage of reward 0 pending to split to the second position" + ], + "type": "u8" + }, + { + "name": "reward_1_percentage", + "docs": [ + "Percentage of reward 1 pending to split to the second position" + ], + "type": "u8" + }, + { + "name": "padding", + "docs": [ + "padding for future" + ], + "type": { + "array": [ + "u8", + 16 + ] + } + } + ] + } + }, + { + "name": "StaticConfigParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool_fees", + "type": { + "defined": { + "name": "PoolFeeParameters" + } + } + }, + { + "name": "sqrt_min_price", + "type": "u128" + }, + { + "name": "sqrt_max_price", + "type": "u128" + }, + { + "name": "vault_config_key", + "type": "pubkey" + }, + { + "name": "pool_creator_authority", + "type": "pubkey" + }, + { + "name": "activation_type", + "type": "u8" + }, + { + "name": "collect_fee_mode", + "type": "u8" + } + ] + } + }, + { + "name": "SwapParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount_in", + "type": "u64" + }, + { + "name": "minimum_amount_out", + "type": "u64" + } + ] + } + }, + { + "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": "TokenBadge", + "docs": [ + "Parameter that set by the protocol" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "token_mint", + "docs": [ + "token mint" + ], + "type": "pubkey" + }, + { + "name": "_padding", + "docs": [ + "Reserve" + ], + "type": { + "array": [ + "u8", + 128 + ] + } + } + ] + } + }, + { + "name": "UserRewardInfo", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "reward_per_token_checkpoint", + "docs": [ + "The latest update reward checkpoint" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "reward_pendings", + "docs": [ + "Current pending rewards" + ], + "type": "u64" + }, + { + "name": "total_claimed_rewards", + "docs": [ + "Total claimed rewards" + ], + "type": "u64" + } + ] + } + }, + { + "name": "Vesting", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "position", + "type": "pubkey" + }, + { + "name": "cliff_point", + "type": "u64" + }, + { + "name": "period_frequency", + "type": "u64" + }, + { + "name": "cliff_unlock_liquidity", + "type": "u128" + }, + { + "name": "liquidity_per_period", + "type": "u128" + }, + { + "name": "total_released_liquidity", + "type": "u128" + }, + { + "name": "number_of_period", + "type": "u16" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 14 + ] + } + }, + { + "name": "padding2", + "type": { + "array": [ + "u128", + 4 + ] + } + } + ] + } + }, + { + "name": "VestingParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "cliff_point", + "type": { + "option": "u64" + } + }, + { + "name": "period_frequency", + "type": "u64" + }, + { + "name": "cliff_unlock_liquidity", + "type": "u128" + }, + { + "name": "liquidity_per_period", + "type": "u128" + }, + { + "name": "number_of_period", + "type": "u16" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/idls/dynamic_bonding_curve.json b/idls/dynamic_bonding_curve.json new file mode 100644 index 0000000..921fed7 --- /dev/null +++ b/idls/dynamic_bonding_curve.json @@ -0,0 +1,6459 @@ +{ + "address": "dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN", + "metadata": { + "name": "dynamic_bonding_curve", + "version": "0.1.6", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "claim_creator_trading_fee", + "discriminator": [ + 82, + 220, + 250, + 189, + 3, + 85, + 107, + 45 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "pool", + "writable": true + }, + { + "name": "token_a_account", + "docs": [ + "The treasury token a account" + ], + "writable": true + }, + { + "name": "token_b_account", + "docs": [ + "The treasury token b account" + ], + "writable": true + }, + { + "name": "base_vault", + "docs": [ + "The vault token account for input token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "quote_vault", + "docs": [ + "The vault token account for output token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "base_mint", + "docs": [ + "The mint of token a" + ], + "relations": [ + "pool" + ] + }, + { + "name": "quote_mint", + "docs": [ + "The mint of token b" + ] + }, + { + "name": "creator", + "signer": true, + "relations": [ + "pool" + ] + }, + { + "name": "token_base_program", + "docs": [ + "Token a program" + ] + }, + { + "name": "token_quote_program", + "docs": [ + "Token b program" + ] + }, + { + "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": "max_base_amount", + "type": "u64" + }, + { + "name": "max_quote_amount", + "type": "u64" + } + ] + }, + { + "name": "claim_protocol_fee", + "discriminator": [ + 165, + 228, + 133, + 48, + 99, + 249, + 255, + 33 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "config", + "relations": [ + "pool" + ] + }, + { + "name": "pool", + "writable": true + }, + { + "name": "base_vault", + "docs": [ + "The vault token account for input token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "quote_vault", + "docs": [ + "The vault token account for output token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "base_mint", + "docs": [ + "The mint of token a" + ], + "relations": [ + "pool" + ] + }, + { + "name": "quote_mint", + "docs": [ + "The mint of token b" + ], + "relations": [ + "config" + ] + }, + { + "name": "token_base_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_base_program" + }, + { + "kind": "account", + "path": "base_mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "token_quote_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_quote_program" + }, + { + "kind": "account", + "path": "quote_mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "claim_fee_operator", + "docs": [ + "Claim fee operator" + ] + }, + { + "name": "operator", + "docs": [ + "Operator" + ], + "signer": true, + "relations": [ + "claim_fee_operator" + ] + }, + { + "name": "token_base_program", + "docs": [ + "Token a program" + ] + }, + { + "name": "token_quote_program", + "docs": [ + "Token b program" + ] + }, + { + "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": "claim_trading_fee", + "discriminator": [ + 8, + 236, + 89, + 49, + 152, + 125, + 177, + 81 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "config", + "relations": [ + "pool" + ] + }, + { + "name": "pool", + "writable": true + }, + { + "name": "token_a_account", + "docs": [ + "The treasury token a account" + ], + "writable": true + }, + { + "name": "token_b_account", + "docs": [ + "The treasury token b account" + ], + "writable": true + }, + { + "name": "base_vault", + "docs": [ + "The vault token account for input token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "quote_vault", + "docs": [ + "The vault token account for output token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "base_mint", + "docs": [ + "The mint of token a" + ], + "relations": [ + "pool" + ] + }, + { + "name": "quote_mint", + "docs": [ + "The mint of token b" + ], + "relations": [ + "config" + ] + }, + { + "name": "fee_claimer", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "token_base_program", + "docs": [ + "Token a program" + ] + }, + { + "name": "token_quote_program", + "docs": [ + "Token b program" + ] + }, + { + "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": "max_amount_a", + "type": "u64" + }, + { + "name": "max_amount_b", + "type": "u64" + } + ] + }, + { + "name": "close_claim_fee_operator", + "discriminator": [ + 38, + 134, + 82, + 216, + 95, + 124, + 17, + 99 + ], + "accounts": [ + { + "name": "claim_fee_operator", + "writable": true + }, + { + "name": "rent_receiver", + "writable": true + }, + { + "name": "admin", + "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": "create_claim_fee_operator", + "docs": [ + "ADMIN FUNCTIONS_ ///" + ], + "discriminator": [ + 169, + 62, + 207, + 107, + 58, + 187, + 162, + 109 + ], + "accounts": [ + { + "name": "claim_fee_operator", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 102, + 95, + 111, + 112, + 101, + 114, + 97, + 116, + 111, + 114 + ] + }, + { + "kind": "account", + "path": "operator" + } + ] + } + }, + { + "name": "operator" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "create_config", + "discriminator": [ + 201, + 207, + 243, + 114, + 75, + 111, + 47, + 189 + ], + "accounts": [ + { + "name": "config", + "writable": true, + "signer": true + }, + { + "name": "fee_claimer" + }, + { + "name": "leftover_receiver" + }, + { + "name": "quote_mint", + "docs": [ + "quote mint" + ] + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "config_parameters", + "type": { + "defined": { + "name": "ConfigParameters" + } + } + } + ] + }, + { + "name": "create_locker", + "docs": [ + "PERMISSIONLESS FUNCTIONS ///", + "create locker" + ], + "discriminator": [ + 167, + 90, + 137, + 154, + 75, + 47, + 17, + 84 + ], + "accounts": [ + { + "name": "virtual_pool", + "docs": [ + "Virtual pool" + ], + "writable": true + }, + { + "name": "config", + "docs": [ + "Config" + ], + "relations": [ + "virtual_pool" + ] + }, + { + "name": "pool_authority", + "writable": true, + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "base_vault", + "writable": true, + "relations": [ + "virtual_pool" + ] + }, + { + "name": "base_mint", + "writable": true, + "relations": [ + "virtual_pool" + ] + }, + { + "name": "base", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 97, + 115, + 101, + 95, + 108, + 111, + 99, + 107, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "virtual_pool" + } + ] + } + }, + { + "name": "creator", + "relations": [ + "virtual_pool" + ] + }, + { + "name": "escrow", + "writable": true + }, + { + "name": "escrow_token", + "writable": true + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "token_program" + }, + { + "name": "locker_program", + "address": "LocpQgucEQHbqNABEYvBvwoxCPsSbG91A1QaQhQQqjn" + }, + { + "name": "locker_event_authority" + }, + { + "name": "system_program", + "docs": [ + "System program." + ], + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "create_partner_metadata", + "docs": [ + "PARTNER FUNCTIONS ////" + ], + "discriminator": [ + 192, + 168, + 234, + 191, + 188, + 226, + 227, + 255 + ], + "accounts": [ + { + "name": "partner_metadata", + "docs": [ + "Partner metadata" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 97, + 114, + 116, + 110, + 101, + 114, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "fee_claimer" + } + ] + } + }, + { + "name": "payer", + "docs": [ + "Payer of the partner metadata." + ], + "writable": true, + "signer": true + }, + { + "name": "fee_claimer", + "docs": [ + "Fee claimer for partner" + ], + "signer": true + }, + { + "name": "system_program", + "docs": [ + "System program." + ], + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "metadata", + "type": { + "defined": { + "name": "CreatePartnerMetadataParameters" + } + } + } + ] + }, + { + "name": "create_virtual_pool_metadata", + "discriminator": [ + 45, + 97, + 187, + 103, + 254, + 109, + 124, + 134 + ], + "accounts": [ + { + "name": "virtual_pool", + "writable": true + }, + { + "name": "virtual_pool_metadata", + "docs": [ + "Virtual pool metadata" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 118, + 105, + 114, + 116, + 117, + 97, + 108, + 95, + 112, + 111, + 111, + 108, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "virtual_pool" + } + ] + } + }, + { + "name": "creator", + "signer": true, + "relations": [ + "virtual_pool" + ] + }, + { + "name": "payer", + "docs": [ + "Payer of the virtual pool metadata." + ], + "writable": true, + "signer": true + }, + { + "name": "system_program", + "docs": [ + "System program." + ], + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "metadata", + "type": { + "defined": { + "name": "CreateVirtualPoolMetadataParameters" + } + } + } + ] + }, + { + "name": "creator_withdraw_surplus", + "discriminator": [ + 165, + 3, + 137, + 7, + 28, + 134, + 76, + 80 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "config", + "relations": [ + "virtual_pool" + ] + }, + { + "name": "virtual_pool", + "writable": true + }, + { + "name": "token_quote_account", + "docs": [ + "The receiver token account" + ], + "writable": true + }, + { + "name": "quote_vault", + "docs": [ + "The vault token account for output token" + ], + "writable": true, + "relations": [ + "virtual_pool" + ] + }, + { + "name": "quote_mint", + "docs": [ + "The mint of quote token" + ], + "relations": [ + "config" + ] + }, + { + "name": "creator", + "signer": true, + "relations": [ + "virtual_pool" + ] + }, + { + "name": "token_quote_program", + "docs": [ + "Token b program" + ] + }, + { + "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": "initialize_virtual_pool_with_spl_token", + "docs": [ + "POOL CREATOR FUNCTIONS ////" + ], + "discriminator": [ + 140, + 85, + 215, + 176, + 102, + 54, + 104, + 79 + ], + "accounts": [ + { + "name": "config", + "docs": [ + "Which config the pool belongs to." + ] + }, + { + "name": "pool_authority", + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "creator", + "signer": true + }, + { + "name": "base_mint", + "writable": true, + "signer": true + }, + { + "name": "quote_mint", + "relations": [ + "config" + ] + }, + { + "name": "pool", + "docs": [ + "Initialize an account to store the pool state" + ], + "writable": true + }, + { + "name": "base_vault", + "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 + ] + }, + { + "kind": "account", + "path": "base_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "quote_vault", + "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 + ] + }, + { + "kind": "account", + "path": "quote_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "mint_metadata", + "writable": true + }, + { + "name": "metadata_program", + "address": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" + }, + { + "name": "payer", + "docs": [ + "Address paying to create the pool. Can be anyone" + ], + "writable": true, + "signer": true + }, + { + "name": "token_quote_program", + "docs": [ + "Program to create mint account and mint tokens" + ] + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "InitializePoolParameters" + } + } + } + ] + }, + { + "name": "initialize_virtual_pool_with_token2022", + "discriminator": [ + 169, + 118, + 51, + 78, + 145, + 110, + 220, + 155 + ], + "accounts": [ + { + "name": "config", + "docs": [ + "Which config the pool belongs to." + ] + }, + { + "name": "pool_authority", + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "creator", + "signer": true + }, + { + "name": "base_mint", + "docs": [ + "Unique token mint address, initialize in contract" + ], + "writable": true, + "signer": true + }, + { + "name": "quote_mint", + "relations": [ + "config" + ] + }, + { + "name": "pool", + "docs": [ + "Initialize an account to store the pool state" + ], + "writable": true + }, + { + "name": "base_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 111, + 107, + 101, + 110, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "base_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "quote_vault", + "docs": [ + "Token quote vault for the pool" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 111, + 107, + 101, + 110, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "quote_mint" + }, + { + "kind": "account", + "path": "pool" + } + ] + } + }, + { + "name": "payer", + "docs": [ + "Address paying to create the pool. Can be anyone" + ], + "writable": true, + "signer": true + }, + { + "name": "token_quote_program", + "docs": [ + "Program to create mint account and mint tokens" + ] + }, + { + "name": "token_program", + "docs": [ + "token program for base mint" + ], + "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "InitializePoolParameters" + } + } + } + ] + }, + { + "name": "migrate_meteora_damm", + "discriminator": [ + 27, + 1, + 48, + 22, + 180, + 63, + 118, + 217 + ], + "accounts": [ + { + "name": "virtual_pool", + "docs": [ + "virtual pool" + ], + "writable": true, + "relations": [ + "migration_metadata" + ] + }, + { + "name": "migration_metadata", + "writable": true + }, + { + "name": "config", + "relations": [ + "virtual_pool" + ] + }, + { + "name": "pool_authority", + "writable": true, + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "pool", + "writable": true + }, + { + "name": "damm_config", + "docs": [ + "pool config" + ] + }, + { + "name": "lp_mint", + "writable": true + }, + { + "name": "token_a_mint", + "writable": true + }, + { + "name": "token_b_mint" + }, + { + "name": "a_vault", + "writable": true + }, + { + "name": "b_vault", + "writable": true + }, + { + "name": "a_token_vault", + "writable": true + }, + { + "name": "b_token_vault", + "writable": true + }, + { + "name": "a_vault_lp_mint", + "writable": true + }, + { + "name": "b_vault_lp_mint", + "writable": true + }, + { + "name": "a_vault_lp", + "writable": true + }, + { + "name": "b_vault_lp", + "writable": true + }, + { + "name": "base_vault", + "writable": true, + "relations": [ + "virtual_pool" + ] + }, + { + "name": "quote_vault", + "writable": true, + "relations": [ + "virtual_pool" + ] + }, + { + "name": "virtual_pool_lp", + "writable": true + }, + { + "name": "protocol_token_a_fee", + "writable": true + }, + { + "name": "protocol_token_b_fee", + "writable": true + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent" + }, + { + "name": "mint_metadata", + "writable": true + }, + { + "name": "metadata_program" + }, + { + "name": "amm_program", + "address": "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB" + }, + { + "name": "vault_program" + }, + { + "name": "token_program", + "docs": [ + "token_program" + ], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "associated_token_program" + }, + { + "name": "system_program", + "docs": [ + "System program." + ], + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "migrate_meteora_damm_claim_lp_token", + "discriminator": [ + 139, + 133, + 2, + 30, + 91, + 145, + 127, + 154 + ], + "accounts": [ + { + "name": "virtual_pool", + "relations": [ + "migration_metadata" + ] + }, + { + "name": "migration_metadata", + "docs": [ + "migration metadata" + ], + "writable": true + }, + { + "name": "pool_authority", + "writable": true, + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "lp_mint", + "relations": [ + "migration_metadata" + ] + }, + { + "name": "source_token", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "pool_authority" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "account", + "path": "migration_metadata" + } + ], + "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": "destination_token", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "owner" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "account", + "path": "migration_metadata" + } + ], + "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": "owner" + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_program", + "docs": [ + "token_program" + ], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [] + }, + { + "name": "migrate_meteora_damm_lock_lp_token", + "discriminator": [ + 177, + 55, + 238, + 157, + 251, + 88, + 165, + 42 + ], + "accounts": [ + { + "name": "virtual_pool", + "relations": [ + "migration_metadata" + ] + }, + { + "name": "migration_metadata", + "docs": [ + "migration_metadata" + ], + "writable": true + }, + { + "name": "pool_authority", + "writable": true, + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "pool", + "writable": true, + "relations": [ + "lock_escrow" + ] + }, + { + "name": "lp_mint", + "relations": [ + "migration_metadata" + ] + }, + { + "name": "lock_escrow", + "writable": true + }, + { + "name": "owner", + "relations": [ + "lock_escrow" + ] + }, + { + "name": "source_tokens", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "pool_authority" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "account", + "path": "migration_metadata" + } + ], + "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": "escrow_vault", + "writable": true + }, + { + "name": "amm_program", + "address": "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB" + }, + { + "name": "a_vault" + }, + { + "name": "b_vault" + }, + { + "name": "a_vault_lp" + }, + { + "name": "b_vault_lp" + }, + { + "name": "a_vault_lp_mint" + }, + { + "name": "b_vault_lp_mint" + }, + { + "name": "token_program", + "docs": [ + "token_program" + ], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [] + }, + { + "name": "migration_damm_v2", + "discriminator": [ + 156, + 169, + 230, + 103, + 53, + 228, + 80, + 64 + ], + "accounts": [ + { + "name": "virtual_pool", + "docs": [ + "virtual pool" + ], + "writable": true, + "relations": [ + "migration_metadata" + ] + }, + { + "name": "migration_metadata", + "docs": [ + "migration metadata" + ] + }, + { + "name": "config", + "docs": [ + "virtual pool config key" + ], + "relations": [ + "virtual_pool" + ] + }, + { + "name": "pool_authority", + "writable": true, + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "pool", + "writable": true + }, + { + "name": "first_position_nft_mint", + "writable": true + }, + { + "name": "first_position_nft_account", + "writable": true + }, + { + "name": "first_position", + "writable": true + }, + { + "name": "second_position_nft_mint", + "writable": true, + "optional": true + }, + { + "name": "second_position_nft_account", + "writable": true, + "optional": true + }, + { + "name": "second_position", + "writable": true, + "optional": true + }, + { + "name": "damm_pool_authority" + }, + { + "name": "amm_program", + "address": "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG" + }, + { + "name": "base_mint", + "writable": true + }, + { + "name": "quote_mint", + "writable": true + }, + { + "name": "token_a_vault", + "writable": true + }, + { + "name": "token_b_vault", + "writable": true + }, + { + "name": "base_vault", + "writable": true, + "relations": [ + "virtual_pool" + ] + }, + { + "name": "quote_vault", + "writable": true, + "relations": [ + "virtual_pool" + ] + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "token_base_program" + }, + { + "name": "token_quote_program" + }, + { + "name": "token_2022_program" + }, + { + "name": "damm_event_authority" + }, + { + "name": "system_program", + "docs": [ + "System program." + ], + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "migration_damm_v2_create_metadata", + "discriminator": [ + 109, + 189, + 19, + 36, + 195, + 183, + 222, + 82 + ], + "accounts": [ + { + "name": "virtual_pool" + }, + { + "name": "config", + "relations": [ + "virtual_pool" + ] + }, + { + "name": "migration_metadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 100, + 97, + 109, + 109, + 95, + 118, + 50 + ] + }, + { + "kind": "account", + "path": "virtual_pool" + } + ] + } + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "migration_meteora_damm_create_metadata", + "docs": [ + "migrate damm v1" + ], + "discriminator": [ + 47, + 94, + 126, + 115, + 221, + 226, + 194, + 133 + ], + "accounts": [ + { + "name": "virtual_pool" + }, + { + "name": "config", + "relations": [ + "virtual_pool" + ] + }, + { + "name": "migration_metadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 116, + 101, + 111, + 114, + 97 + ] + }, + { + "kind": "account", + "path": "virtual_pool" + } + ] + } + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "partner_withdraw_surplus", + "discriminator": [ + 168, + 173, + 72, + 100, + 201, + 98, + 38, + 92 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "config", + "relations": [ + "virtual_pool" + ] + }, + { + "name": "virtual_pool", + "writable": true + }, + { + "name": "token_quote_account", + "docs": [ + "The receiver token account" + ], + "writable": true + }, + { + "name": "quote_vault", + "docs": [ + "The vault token account for output token" + ], + "writable": true, + "relations": [ + "virtual_pool" + ] + }, + { + "name": "quote_mint", + "docs": [ + "The mint of quote token" + ], + "relations": [ + "config" + ] + }, + { + "name": "fee_claimer", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "token_quote_program", + "docs": [ + "Token b program" + ] + }, + { + "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": "protocol_withdraw_surplus", + "discriminator": [ + 54, + 136, + 225, + 138, + 172, + 182, + 214, + 167 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "config", + "relations": [ + "virtual_pool" + ] + }, + { + "name": "virtual_pool", + "writable": true + }, + { + "name": "token_quote_account", + "docs": [ + "The treasury quote token 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_quote_program" + }, + { + "kind": "account", + "path": "quote_mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "quote_vault", + "docs": [ + "The vault token account for quote token" + ], + "writable": true, + "relations": [ + "virtual_pool" + ] + }, + { + "name": "quote_mint", + "docs": [ + "The mint of token" + ], + "relations": [ + "config" + ] + }, + { + "name": "token_quote_program", + "docs": [ + "Token b program" + ] + }, + { + "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": "swap", + "docs": [ + "TRADING BOTS FUNCTIONS ////" + ], + "discriminator": [ + 248, + 198, + 158, + 145, + 225, + 117, + 135, + 200 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "config", + "docs": [ + "config key" + ], + "relations": [ + "pool" + ] + }, + { + "name": "pool", + "docs": [ + "Pool account" + ], + "writable": true + }, + { + "name": "input_token_account", + "docs": [ + "The user token account for input token" + ], + "writable": true + }, + { + "name": "output_token_account", + "docs": [ + "The user token account for output token" + ], + "writable": true + }, + { + "name": "base_vault", + "docs": [ + "The vault token account for base token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "quote_vault", + "docs": [ + "The vault token account for quote token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "base_mint", + "docs": [ + "The mint of base token" + ] + }, + { + "name": "quote_mint", + "docs": [ + "The mint of quote token" + ] + }, + { + "name": "payer", + "docs": [ + "The user performing the swap" + ], + "signer": true + }, + { + "name": "token_base_program", + "docs": [ + "Token base program" + ] + }, + { + "name": "token_quote_program", + "docs": [ + "Token quote program" + ] + }, + { + "name": "referral_token_account", + "docs": [ + "referral token account" + ], + "writable": true, + "optional": 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": "params", + "type": { + "defined": { + "name": "SwapParameters" + } + } + } + ] + }, + { + "name": "swap2", + "discriminator": [ + 65, + 75, + 63, + 76, + 235, + 91, + 91, + 136 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "config", + "docs": [ + "config key" + ], + "relations": [ + "pool" + ] + }, + { + "name": "pool", + "docs": [ + "Pool account" + ], + "writable": true + }, + { + "name": "input_token_account", + "docs": [ + "The user token account for input token" + ], + "writable": true + }, + { + "name": "output_token_account", + "docs": [ + "The user token account for output token" + ], + "writable": true + }, + { + "name": "base_vault", + "docs": [ + "The vault token account for base token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "quote_vault", + "docs": [ + "The vault token account for quote token" + ], + "writable": true, + "relations": [ + "pool" + ] + }, + { + "name": "base_mint", + "docs": [ + "The mint of base token" + ] + }, + { + "name": "quote_mint", + "docs": [ + "The mint of quote token" + ] + }, + { + "name": "payer", + "docs": [ + "The user performing the swap" + ], + "signer": true + }, + { + "name": "token_base_program", + "docs": [ + "Token base program" + ] + }, + { + "name": "token_quote_program", + "docs": [ + "Token quote program" + ] + }, + { + "name": "referral_token_account", + "docs": [ + "referral token account" + ], + "writable": true, + "optional": 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": "params", + "type": { + "defined": { + "name": "SwapParameters2" + } + } + } + ] + }, + { + "name": "transfer_pool_creator", + "discriminator": [ + 20, + 7, + 169, + 33, + 58, + 147, + 166, + 33 + ], + "accounts": [ + { + "name": "virtual_pool", + "writable": true + }, + { + "name": "config", + "relations": [ + "virtual_pool" + ] + }, + { + "name": "creator", + "signer": true, + "relations": [ + "virtual_pool" + ] + }, + { + "name": "new_creator" + }, + { + "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": "withdraw_leftover", + "discriminator": [ + 20, + 198, + 202, + 237, + 235, + 243, + 183, + 66 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "config", + "relations": [ + "virtual_pool" + ] + }, + { + "name": "virtual_pool", + "writable": true + }, + { + "name": "token_base_account", + "docs": [ + "The receiver token account, withdraw to ATA" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "leftover_receiver" + }, + { + "kind": "account", + "path": "token_base_program" + }, + { + "kind": "account", + "path": "base_mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "base_vault", + "docs": [ + "The vault token account for output token" + ], + "writable": true, + "relations": [ + "virtual_pool" + ] + }, + { + "name": "base_mint", + "docs": [ + "The mint of quote token" + ], + "relations": [ + "virtual_pool" + ] + }, + { + "name": "leftover_receiver", + "relations": [ + "config" + ] + }, + { + "name": "token_base_program", + "docs": [ + "Token base program" + ] + }, + { + "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": "withdraw_migration_fee", + "docs": [ + "BOTH partner and creator FUNCTIONS ///" + ], + "discriminator": [ + 237, + 142, + 45, + 23, + 129, + 6, + 222, + 162 + ], + "accounts": [ + { + "name": "pool_authority", + "address": "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM" + }, + { + "name": "config", + "relations": [ + "virtual_pool" + ] + }, + { + "name": "virtual_pool", + "writable": true + }, + { + "name": "token_quote_account", + "docs": [ + "The receiver token account" + ], + "writable": true + }, + { + "name": "quote_vault", + "docs": [ + "The vault token account for output token" + ], + "writable": true, + "relations": [ + "virtual_pool" + ] + }, + { + "name": "quote_mint", + "docs": [ + "The mint of quote token" + ], + "relations": [ + "config" + ] + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_quote_program", + "docs": [ + "Token b program" + ] + }, + { + "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": "flag", + "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": "LockEscrow", + "discriminator": [ + 190, + 106, + 121, + 6, + 200, + 182, + 21, + 75 + ] + }, + { + "name": "MeteoraDammMigrationMetadata", + "discriminator": [ + 17, + 155, + 141, + 215, + 207, + 4, + 133, + 156 + ] + }, + { + "name": "MeteoraDammV2Metadata", + "discriminator": [ + 104, + 221, + 219, + 203, + 10, + 142, + 250, + 163 + ] + }, + { + "name": "PartnerMetadata", + "discriminator": [ + 68, + 68, + 130, + 19, + 16, + 209, + 98, + 156 + ] + }, + { + "name": "PoolConfig", + "discriminator": [ + 26, + 108, + 14, + 123, + 116, + 230, + 129, + 43 + ] + }, + { + "name": "VirtualPool", + "discriminator": [ + 213, + 224, + 5, + 209, + 98, + 69, + 119, + 92 + ] + }, + { + "name": "VirtualPoolMetadata", + "discriminator": [ + 217, + 37, + 82, + 250, + 43, + 47, + 228, + 254 + ] + } + ], + "events": [ + { + "name": "EvtClaimCreatorTradingFee", + "discriminator": [ + 154, + 228, + 215, + 202, + 133, + 155, + 214, + 138 + ] + }, + { + "name": "EvtClaimProtocolFee", + "discriminator": [ + 186, + 244, + 75, + 251, + 188, + 13, + 25, + 33 + ] + }, + { + "name": "EvtClaimTradingFee", + "discriminator": [ + 26, + 83, + 117, + 240, + 92, + 202, + 112, + 254 + ] + }, + { + "name": "EvtCloseClaimFeeOperator", + "discriminator": [ + 111, + 39, + 37, + 55, + 110, + 216, + 194, + 23 + ] + }, + { + "name": "EvtCreateClaimFeeOperator", + "discriminator": [ + 21, + 6, + 153, + 120, + 68, + 116, + 28, + 177 + ] + }, + { + "name": "EvtCreateConfig", + "discriminator": [ + 131, + 207, + 180, + 174, + 180, + 73, + 165, + 54 + ] + }, + { + "name": "EvtCreateConfigV2", + "discriminator": [ + 163, + 74, + 66, + 187, + 119, + 195, + 26, + 144 + ] + }, + { + "name": "EvtCreateDammV2MigrationMetadata", + "discriminator": [ + 103, + 111, + 132, + 168, + 140, + 253, + 150, + 114 + ] + }, + { + "name": "EvtCreateMeteoraMigrationMetadata", + "discriminator": [ + 99, + 167, + 133, + 63, + 214, + 143, + 175, + 139 + ] + }, + { + "name": "EvtCreatorWithdrawSurplus", + "discriminator": [ + 152, + 73, + 21, + 15, + 66, + 87, + 53, + 157 + ] + }, + { + "name": "EvtCurveComplete", + "discriminator": [ + 229, + 231, + 86, + 84, + 156, + 134, + 75, + 24 + ] + }, + { + "name": "EvtInitializePool", + "discriminator": [ + 228, + 50, + 246, + 85, + 203, + 66, + 134, + 37 + ] + }, + { + "name": "EvtPartnerMetadata", + "discriminator": [ + 200, + 127, + 6, + 55, + 13, + 32, + 8, + 150 + ] + }, + { + "name": "EvtPartnerWithdrawMigrationFee", + "discriminator": [ + 181, + 105, + 127, + 67, + 8, + 187, + 120, + 57 + ] + }, + { + "name": "EvtPartnerWithdrawSurplus", + "discriminator": [ + 195, + 56, + 152, + 9, + 232, + 72, + 35, + 22 + ] + }, + { + "name": "EvtProtocolWithdrawSurplus", + "discriminator": [ + 109, + 111, + 28, + 221, + 134, + 195, + 230, + 203 + ] + }, + { + "name": "EvtSwap", + "discriminator": [ + 27, + 60, + 21, + 213, + 138, + 170, + 187, + 147 + ] + }, + { + "name": "EvtSwap2", + "discriminator": [ + 189, + 66, + 51, + 168, + 38, + 80, + 117, + 153 + ] + }, + { + "name": "EvtUpdatePoolCreator", + "discriminator": [ + 107, + 225, + 165, + 237, + 91, + 158, + 213, + 220 + ] + }, + { + "name": "EvtVirtualPoolMetadata", + "discriminator": [ + 188, + 18, + 72, + 76, + 195, + 91, + 38, + 74 + ] + }, + { + "name": "EvtWithdrawLeftover", + "discriminator": [ + 191, + 189, + 104, + 143, + 111, + 156, + 94, + 229 + ] + }, + { + "name": "EvtWithdrawMigrationFee", + "discriminator": [ + 26, + 203, + 84, + 85, + 161, + 23, + 100, + 214 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "MathOverflow", + "msg": "Math operation overflow" + }, + { + "code": 6001, + "name": "InvalidFee", + "msg": "Invalid fee setup" + }, + { + "code": 6002, + "name": "ExceededSlippage", + "msg": "Exceeded slippage tolerance" + }, + { + "code": 6003, + "name": "ExceedMaxFeeBps", + "msg": "Exceeded max fee bps" + }, + { + "code": 6004, + "name": "InvalidAdmin", + "msg": "Invalid admin" + }, + { + "code": 6005, + "name": "AmountIsZero", + "msg": "Amount is zero" + }, + { + "code": 6006, + "name": "TypeCastFailed", + "msg": "Type cast error" + }, + { + "code": 6007, + "name": "InvalidActivationType", + "msg": "Invalid activation type" + }, + { + "code": 6008, + "name": "InvalidQuoteMint", + "msg": "Invalid quote mint" + }, + { + "code": 6009, + "name": "InvalidCollectFeeMode", + "msg": "Invalid collect fee mode" + }, + { + "code": 6010, + "name": "InvalidMigrationFeeOption", + "msg": "Invalid migration fee option" + }, + { + "code": 6011, + "name": "InvalidInput", + "msg": "Invalid input" + }, + { + "code": 6012, + "name": "NotEnoughLiquidity", + "msg": "Not enough liquidity" + }, + { + "code": 6013, + "name": "PoolIsCompleted", + "msg": "Pool is completed" + }, + { + "code": 6014, + "name": "PoolIsIncompleted", + "msg": "Pool is incompleted" + }, + { + "code": 6015, + "name": "InvalidMigrationOption", + "msg": "Invalid migration option" + }, + { + "code": 6016, + "name": "InvalidTokenDecimals", + "msg": "Invalid activation type" + }, + { + "code": 6017, + "name": "InvalidTokenType", + "msg": "Invalid token type" + }, + { + "code": 6018, + "name": "InvalidFeePercentage", + "msg": "Invalid fee percentage" + }, + { + "code": 6019, + "name": "InvalidQuoteThreshold", + "msg": "Invalid quote threshold" + }, + { + "code": 6020, + "name": "InvalidTokenSupply", + "msg": "Invalid token supply" + }, + { + "code": 6021, + "name": "InvalidCurve", + "msg": "Invalid curve" + }, + { + "code": 6022, + "name": "NotPermitToDoThisAction", + "msg": "Not permit to do this action" + }, + { + "code": 6023, + "name": "InvalidOwnerAccount", + "msg": "Invalid owner account" + }, + { + "code": 6024, + "name": "InvalidConfigAccount", + "msg": "Invalid config account" + }, + { + "code": 6025, + "name": "SurplusHasBeenWithdraw", + "msg": "Surplus has been withdraw" + }, + { + "code": 6026, + "name": "LeftoverHasBeenWithdraw", + "msg": "Leftover has been withdraw" + }, + { + "code": 6027, + "name": "TotalBaseTokenExceedMaxSupply", + "msg": "Total base token is exceeded max supply" + }, + { + "code": 6028, + "name": "UnsupportNativeMintToken2022", + "msg": "Unsupport native mint token 2022" + }, + { + "code": 6029, + "name": "InsufficientLiquidityForMigration", + "msg": "Insufficient liquidity for migration" + }, + { + "code": 6030, + "name": "MissingPoolConfigInRemainingAccount", + "msg": "Missing pool config in remaining account" + }, + { + "code": 6031, + "name": "InvalidVestingParameters", + "msg": "Invalid vesting parameters" + }, + { + "code": 6032, + "name": "InvalidLeftoverAddress", + "msg": "Invalid leftover address" + }, + { + "code": 6033, + "name": "SwapAmountIsOverAThreshold", + "msg": "Swap amount is over a threshold" + }, + { + "code": 6034, + "name": "InvalidFeeScheduler", + "msg": "Invalid fee scheduler" + }, + { + "code": 6035, + "name": "InvalidCreatorTradingFeePercentage", + "msg": "Invalid creator trading fee percentage" + }, + { + "code": 6036, + "name": "InvalidNewCreator", + "msg": "Invalid new creator" + }, + { + "code": 6037, + "name": "InvalidTokenAuthorityOption", + "msg": "Invalid token authority option" + }, + { + "code": 6038, + "name": "InvalidAccount", + "msg": "Invalid account for the instruction" + }, + { + "code": 6039, + "name": "InvalidMigratorFeePercentage", + "msg": "Invalid migrator fee percentage" + }, + { + "code": 6040, + "name": "MigrationFeeHasBeenWithdraw", + "msg": "Migration fee has been withdraw" + }, + { + "code": 6041, + "name": "InvalidBaseFeeMode", + "msg": "Invalid base fee mode" + }, + { + "code": 6042, + "name": "InvalidFeeRateLimiter", + "msg": "Invalid fee rate limiter" + }, + { + "code": 6043, + "name": "FailToValidateSingleSwapInstruction", + "msg": "Fail to validate single swap instruction in rate limiter" + }, + { + "code": 6044, + "name": "InvalidMigratedPoolFee", + "msg": "Invalid migrated pool fee params" + }, + { + "code": 6045, + "name": "UndeterminedError", + "msg": "Undertermined error" + }, + { + "code": 6046, + "name": "RateLimiterNotSupported", + "msg": "Rate limiter not supported" + }, + { + "code": 6047, + "name": "AmountLeftIsNotZero", + "msg": "Amount left is not zero" + }, + { + "code": 6048, + "name": "NextSqrtPriceIsSmallerThanStartSqrtPrice", + "msg": "Next sqrt price is smaller than start sqrt price" + } + ], + "types": [ + { + "name": "BaseFeeConfig", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "cliff_fee_numerator", + "type": "u64" + }, + { + "name": "second_factor", + "type": "u64" + }, + { + "name": "third_factor", + "type": "u64" + }, + { + "name": "first_factor", + "type": "u16" + }, + { + "name": "base_fee_mode", + "type": "u8" + }, + { + "name": "padding_0", + "type": { + "array": [ + "u8", + 5 + ] + } + } + ] + } + }, + { + "name": "BaseFeeParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "cliff_fee_numerator", + "type": "u64" + }, + { + "name": "first_factor", + "type": "u16" + }, + { + "name": "second_factor", + "type": "u64" + }, + { + "name": "third_factor", + "type": "u64" + }, + { + "name": "base_fee_mode", + "type": "u8" + } + ] + } + }, + { + "name": "ClaimFeeOperator", + "docs": [ + "Parameter that set by the protocol" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "operator", + "docs": [ + "operator" + ], + "type": "pubkey" + }, + { + "name": "_padding", + "docs": [ + "Reserve" + ], + "type": { + "array": [ + "u8", + 128 + ] + } + } + ] + } + }, + { + "name": "Config", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool_fees", + "type": { + "defined": { + "name": "PoolFees" + } + } + }, + { + "name": "activation_duration", + "type": "u64" + }, + { + "name": "vault_config_key", + "type": "pubkey" + }, + { + "name": "pool_creator_authority", + "type": "pubkey" + }, + { + "name": "activation_type", + "type": "u8" + }, + { + "name": "partner_fee_numerator", + "type": "u64" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 219 + ] + } + } + ] + } + }, + { + "name": "ConfigParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool_fees", + "type": { + "defined": { + "name": "PoolFeeParameters" + } + } + }, + { + "name": "collect_fee_mode", + "type": "u8" + }, + { + "name": "migration_option", + "type": "u8" + }, + { + "name": "activation_type", + "type": "u8" + }, + { + "name": "token_type", + "type": "u8" + }, + { + "name": "token_decimal", + "type": "u8" + }, + { + "name": "partner_lp_percentage", + "type": "u8" + }, + { + "name": "partner_locked_lp_percentage", + "type": "u8" + }, + { + "name": "creator_lp_percentage", + "type": "u8" + }, + { + "name": "creator_locked_lp_percentage", + "type": "u8" + }, + { + "name": "migration_quote_threshold", + "type": "u64" + }, + { + "name": "sqrt_start_price", + "type": "u128" + }, + { + "name": "locked_vesting", + "type": { + "defined": { + "name": "LockedVestingParams" + } + } + }, + { + "name": "migration_fee_option", + "type": "u8" + }, + { + "name": "token_supply", + "type": { + "option": { + "defined": { + "name": "TokenSupplyParams" + } + } + } + }, + { + "name": "creator_trading_fee_percentage", + "type": "u8" + }, + { + "name": "token_update_authority", + "type": "u8" + }, + { + "name": "migration_fee", + "type": { + "defined": { + "name": "MigrationFee" + } + } + }, + { + "name": "migrated_pool_fee", + "type": { + "defined": { + "name": "MigratedPoolFee" + } + } + }, + { + "name": "padding", + "docs": [ + "padding for future use" + ], + "type": { + "array": [ + "u64", + 7 + ] + } + }, + { + "name": "curve", + "type": { + "vec": { + "defined": { + "name": "LiquidityDistributionParameters" + } + } + } + } + ] + } + }, + { + "name": "CreatePartnerMetadataParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "padding", + "type": { + "array": [ + "u8", + 96 + ] + } + }, + { + "name": "name", + "type": "string" + }, + { + "name": "website", + "type": "string" + }, + { + "name": "logo", + "type": "string" + } + ] + } + }, + { + "name": "CreateVirtualPoolMetadataParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "padding", + "type": { + "array": [ + "u8", + 96 + ] + } + }, + { + "name": "name", + "type": "string" + }, + { + "name": "website", + "type": "string" + }, + { + "name": "logo", + "type": "string" + } + ] + } + }, + { + "name": "DynamicFeeConfig", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "initialized", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 7 + ] + } + }, + { + "name": "max_volatility_accumulator", + "type": "u32" + }, + { + "name": "variable_fee_control", + "type": "u32" + }, + { + "name": "bin_step", + "type": "u16" + }, + { + "name": "filter_period", + "type": "u16" + }, + { + "name": "decay_period", + "type": "u16" + }, + { + "name": "reduction_factor", + "type": "u16" + }, + { + "name": "padding2", + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "bin_step_u128", + "type": "u128" + } + ] + } + }, + { + "name": "DynamicFeeParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bin_step", + "type": "u16" + }, + { + "name": "bin_step_u128", + "type": "u128" + }, + { + "name": "filter_period", + "type": "u16" + }, + { + "name": "decay_period", + "type": "u16" + }, + { + "name": "reduction_factor", + "type": "u16" + }, + { + "name": "max_volatility_accumulator", + "type": "u32" + }, + { + "name": "variable_fee_control", + "type": "u32" + } + ] + } + }, + { + "name": "EvtClaimCreatorTradingFee", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "token_base_amount", + "type": "u64" + }, + { + "name": "token_quote_amount", + "type": "u64" + } + ] + } + }, + { + "name": "EvtClaimProtocolFee", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "token_base_amount", + "type": "u64" + }, + { + "name": "token_quote_amount", + "type": "u64" + } + ] + } + }, + { + "name": "EvtClaimTradingFee", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "token_base_amount", + "type": "u64" + }, + { + "name": "token_quote_amount", + "type": "u64" + } + ] + } + }, + { + "name": "EvtCloseClaimFeeOperator", + "docs": [ + "Close claim fee operator" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "claim_fee_operator", + "type": "pubkey" + }, + { + "name": "operator", + "type": "pubkey" + } + ] + } + }, + { + "name": "EvtCreateClaimFeeOperator", + "docs": [ + "Create claim fee operator" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "operator", + "type": "pubkey" + } + ] + } + }, + { + "name": "EvtCreateConfig", + "docs": [ + "Create config" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "config", + "type": "pubkey" + }, + { + "name": "quote_mint", + "type": "pubkey" + }, + { + "name": "fee_claimer", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "pool_fees", + "type": { + "defined": { + "name": "PoolFeeParameters" + } + } + }, + { + "name": "collect_fee_mode", + "type": "u8" + }, + { + "name": "migration_option", + "type": "u8" + }, + { + "name": "activation_type", + "type": "u8" + }, + { + "name": "token_decimal", + "type": "u8" + }, + { + "name": "token_type", + "type": "u8" + }, + { + "name": "partner_locked_lp_percentage", + "type": "u8" + }, + { + "name": "partner_lp_percentage", + "type": "u8" + }, + { + "name": "creator_locked_lp_percentage", + "type": "u8" + }, + { + "name": "creator_lp_percentage", + "type": "u8" + }, + { + "name": "swap_base_amount", + "type": "u64" + }, + { + "name": "migration_quote_threshold", + "type": "u64" + }, + { + "name": "migration_base_amount", + "type": "u64" + }, + { + "name": "sqrt_start_price", + "type": "u128" + }, + { + "name": "locked_vesting", + "type": { + "defined": { + "name": "LockedVestingParams" + } + } + }, + { + "name": "migration_fee_option", + "type": "u8" + }, + { + "name": "fixed_token_supply_flag", + "type": "u8" + }, + { + "name": "pre_migration_token_supply", + "type": "u64" + }, + { + "name": "post_migration_token_supply", + "type": "u64" + }, + { + "name": "curve", + "type": { + "vec": { + "defined": { + "name": "LiquidityDistributionParameters" + } + } + } + } + ] + } + }, + { + "name": "EvtCreateConfigV2", + "type": { + "kind": "struct", + "fields": [ + { + "name": "config", + "type": "pubkey" + }, + { + "name": "quote_mint", + "type": "pubkey" + }, + { + "name": "fee_claimer", + "type": "pubkey" + }, + { + "name": "leftover_receiver", + "type": "pubkey" + }, + { + "name": "config_parameters", + "type": { + "defined": { + "name": "ConfigParameters" + } + } + } + ] + } + }, + { + "name": "EvtCreateDammV2MigrationMetadata", + "type": { + "kind": "struct", + "fields": [ + { + "name": "virtual_pool", + "type": "pubkey" + } + ] + } + }, + { + "name": "EvtCreateMeteoraMigrationMetadata", + "type": { + "kind": "struct", + "fields": [ + { + "name": "virtual_pool", + "type": "pubkey" + } + ] + } + }, + { + "name": "EvtCreatorWithdrawSurplus", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "surplus_amount", + "type": "u64" + } + ] + } + }, + { + "name": "EvtCurveComplete", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "config", + "type": "pubkey" + }, + { + "name": "base_reserve", + "type": "u64" + }, + { + "name": "quote_reserve", + "type": "u64" + } + ] + } + }, + { + "name": "EvtInitializePool", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "config", + "type": "pubkey" + }, + { + "name": "creator", + "type": "pubkey" + }, + { + "name": "base_mint", + "type": "pubkey" + }, + { + "name": "pool_type", + "type": "u8" + }, + { + "name": "activation_point", + "type": "u64" + } + ] + } + }, + { + "name": "EvtPartnerMetadata", + "docs": [ + "Create partner metadata" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "partner_metadata", + "type": "pubkey" + }, + { + "name": "fee_claimer", + "type": "pubkey" + } + ] + } + }, + { + "name": "EvtPartnerWithdrawMigrationFee", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "fee", + "type": "u64" + } + ] + } + }, + { + "name": "EvtPartnerWithdrawSurplus", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "surplus_amount", + "type": "u64" + } + ] + } + }, + { + "name": "EvtProtocolWithdrawSurplus", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "surplus_amount", + "type": "u64" + } + ] + } + }, + { + "name": "EvtSwap", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "config", + "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": "amount_in", + "type": "u64" + }, + { + "name": "current_timestamp", + "type": "u64" + } + ] + } + }, + { + "name": "EvtSwap2", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "config", + "type": "pubkey" + }, + { + "name": "trade_direction", + "type": "u8" + }, + { + "name": "has_referral", + "type": "bool" + }, + { + "name": "swap_parameters", + "type": { + "defined": { + "name": "SwapParameters2" + } + } + }, + { + "name": "swap_result", + "type": { + "defined": { + "name": "SwapResult2" + } + } + }, + { + "name": "quote_reserve_amount", + "type": "u64" + }, + { + "name": "migration_threshold", + "type": "u64" + }, + { + "name": "current_timestamp", + "type": "u64" + } + ] + } + }, + { + "name": "EvtUpdatePoolCreator", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "creator", + "type": "pubkey" + }, + { + "name": "new_creator", + "type": "pubkey" + } + ] + } + }, + { + "name": "EvtVirtualPoolMetadata", + "docs": [ + "Create virtual pool metadata" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "virtual_pool_metadata", + "type": "pubkey" + }, + { + "name": "virtual_pool", + "type": "pubkey" + } + ] + } + }, + { + "name": "EvtWithdrawLeftover", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "leftover_receiver", + "type": "pubkey" + }, + { + "name": "leftover_amount", + "type": "u64" + } + ] + } + }, + { + "name": "EvtWithdrawMigrationFee", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "fee", + "type": "u64" + }, + { + "name": "flag", + "type": "u8" + } + ] + } + }, + { + "name": "InitializePoolParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "name", + "type": "string" + }, + { + "name": "symbol", + "type": "string" + }, + { + "name": "uri", + "type": "string" + } + ] + } + }, + { + "name": "LiquidityDistributionConfig", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "sqrt_price", + "type": "u128" + }, + { + "name": "liquidity", + "type": "u128" + } + ] + } + }, + { + "name": "LiquidityDistributionParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "sqrt_price", + "type": "u128" + }, + { + "name": "liquidity", + "type": "u128" + } + ] + } + }, + { + "name": "LockEscrow", + "docs": [ + "State of lock escrow account" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "escrow_vault", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "total_locked_amount", + "type": "u64" + }, + { + "name": "lp_per_token", + "type": "u128" + }, + { + "name": "unclaimed_fee_pending", + "type": "u64" + }, + { + "name": "a_fee", + "type": "u64" + }, + { + "name": "b_fee", + "type": "u64" + } + ] + } + }, + { + "name": "LockedVestingConfig", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount_per_period", + "type": "u64" + }, + { + "name": "cliff_duration_from_migration_time", + "type": "u64" + }, + { + "name": "frequency", + "type": "u64" + }, + { + "name": "number_of_period", + "type": "u64" + }, + { + "name": "cliff_unlock_amount", + "type": "u64" + }, + { + "name": "_padding", + "type": "u64" + } + ] + } + }, + { + "name": "LockedVestingParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount_per_period", + "type": "u64" + }, + { + "name": "cliff_duration_from_migration_time", + "type": "u64" + }, + { + "name": "frequency", + "type": "u64" + }, + { + "name": "number_of_period", + "type": "u64" + }, + { + "name": "cliff_unlock_amount", + "type": "u64" + } + ] + } + }, + { + "name": "MeteoraDammMigrationMetadata", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "virtual_pool", + "docs": [ + "pool" + ], + "type": "pubkey" + }, + { + "name": "padding_0", + "docs": [ + "!!! BE CAREFUL to use tomestone field, previous is pool creator" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "partner", + "docs": [ + "partner" + ], + "type": "pubkey" + }, + { + "name": "lp_mint", + "docs": [ + "lp mint" + ], + "type": "pubkey" + }, + { + "name": "partner_locked_lp", + "docs": [ + "partner locked lp" + ], + "type": "u64" + }, + { + "name": "partner_lp", + "docs": [ + "partner lp" + ], + "type": "u64" + }, + { + "name": "creator_locked_lp", + "docs": [ + "creator locked lp" + ], + "type": "u64" + }, + { + "name": "creator_lp", + "docs": [ + "creator lp" + ], + "type": "u64" + }, + { + "name": "_padding_0", + "docs": [ + "padding" + ], + "type": "u8" + }, + { + "name": "creator_locked_status", + "docs": [ + "flag to check whether lp is locked for creator" + ], + "type": "u8" + }, + { + "name": "partner_locked_status", + "docs": [ + "flag to check whether lp is locked for partner" + ], + "type": "u8" + }, + { + "name": "creator_claim_status", + "docs": [ + "flag to check whether creator has claimed lp token" + ], + "type": "u8" + }, + { + "name": "partner_claim_status", + "docs": [ + "flag to check whether partner has claimed lp token" + ], + "type": "u8" + }, + { + "name": "_padding", + "docs": [ + "Reserve" + ], + "type": { + "array": [ + "u8", + 107 + ] + } + } + ] + } + }, + { + "name": "MeteoraDammV2Metadata", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "virtual_pool", + "docs": [ + "pool" + ], + "type": "pubkey" + }, + { + "name": "padding_0", + "docs": [ + "!!! BE CAREFUL to use tomestone field, previous is pool creator" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "partner", + "docs": [ + "partner" + ], + "type": "pubkey" + }, + { + "name": "_padding", + "docs": [ + "Reserve" + ], + "type": { + "array": [ + "u8", + 126 + ] + } + } + ] + } + }, + { + "name": "MigratedPoolFee", + "type": { + "kind": "struct", + "fields": [ + { + "name": "collect_fee_mode", + "type": "u8" + }, + { + "name": "dynamic_fee", + "type": "u8" + }, + { + "name": "pool_fee_bps", + "type": "u16" + } + ] + } + }, + { + "name": "MigrationFee", + "type": { + "kind": "struct", + "fields": [ + { + "name": "fee_percentage", + "type": "u8" + }, + { + "name": "creator_fee_percentage", + "type": "u8" + } + ] + } + }, + { + "name": "PartnerMetadata", + "docs": [ + "Metadata for a partner." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "fee_claimer", + "docs": [ + "fee claimer" + ], + "type": "pubkey" + }, + { + "name": "padding", + "docs": [ + "padding for future use" + ], + "type": { + "array": [ + "u128", + 6 + ] + } + }, + { + "name": "name", + "docs": [ + "Name of partner." + ], + "type": "string" + }, + { + "name": "website", + "docs": [ + "Website of partner." + ], + "type": "string" + }, + { + "name": "logo", + "docs": [ + "Logo of partner" + ], + "type": "string" + } + ] + } + }, + { + "name": "PoolConfig", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "quote_mint", + "docs": [ + "quote mint" + ], + "type": "pubkey" + }, + { + "name": "fee_claimer", + "docs": [ + "Address to get the fee" + ], + "type": "pubkey" + }, + { + "name": "leftover_receiver", + "docs": [ + "Address to receive extra base token after migration, in case token is fixed supply" + ], + "type": "pubkey" + }, + { + "name": "pool_fees", + "docs": [ + "Pool fee" + ], + "type": { + "defined": { + "name": "PoolFeesConfig" + } + } + }, + { + "name": "collect_fee_mode", + "docs": [ + "Collect fee mode" + ], + "type": "u8" + }, + { + "name": "migration_option", + "docs": [ + "migration option" + ], + "type": "u8" + }, + { + "name": "activation_type", + "docs": [ + "whether mode slot or timestamp" + ], + "type": "u8" + }, + { + "name": "token_decimal", + "docs": [ + "token decimals" + ], + "type": "u8" + }, + { + "name": "version", + "docs": [ + "version" + ], + "type": "u8" + }, + { + "name": "token_type", + "docs": [ + "token type of base token" + ], + "type": "u8" + }, + { + "name": "quote_token_flag", + "docs": [ + "quote token flag" + ], + "type": "u8" + }, + { + "name": "partner_locked_lp_percentage", + "docs": [ + "partner locked lp percentage" + ], + "type": "u8" + }, + { + "name": "partner_lp_percentage", + "docs": [ + "partner lp percentage" + ], + "type": "u8" + }, + { + "name": "creator_locked_lp_percentage", + "docs": [ + "creator post migration fee percentage" + ], + "type": "u8" + }, + { + "name": "creator_lp_percentage", + "docs": [ + "creator lp percentage" + ], + "type": "u8" + }, + { + "name": "migration_fee_option", + "docs": [ + "migration fee option" + ], + "type": "u8" + }, + { + "name": "fixed_token_supply_flag", + "docs": [ + "flag to indicate whether token is dynamic supply (0) or fixed supply (1)" + ], + "type": "u8" + }, + { + "name": "creator_trading_fee_percentage", + "docs": [ + "creator trading fee percentage" + ], + "type": "u8" + }, + { + "name": "token_update_authority", + "docs": [ + "token update authority" + ], + "type": "u8" + }, + { + "name": "migration_fee_percentage", + "docs": [ + "migration fee percentage" + ], + "type": "u8" + }, + { + "name": "creator_migration_fee_percentage", + "docs": [ + "creator migration fee percentage" + ], + "type": "u8" + }, + { + "name": "_padding_0", + "docs": [ + "padding 0" + ], + "type": { + "array": [ + "u8", + 7 + ] + } + }, + { + "name": "swap_base_amount", + "docs": [ + "swap base amount" + ], + "type": "u64" + }, + { + "name": "migration_quote_threshold", + "docs": [ + "migration quote threshold (in quote token)" + ], + "type": "u64" + }, + { + "name": "migration_base_threshold", + "docs": [ + "migration base threshold (in base token)" + ], + "type": "u64" + }, + { + "name": "migration_sqrt_price", + "docs": [ + "migration sqrt price" + ], + "type": "u128" + }, + { + "name": "locked_vesting_config", + "docs": [ + "locked vesting config" + ], + "type": { + "defined": { + "name": "LockedVestingConfig" + } + } + }, + { + "name": "pre_migration_token_supply", + "docs": [ + "pre migration token supply" + ], + "type": "u64" + }, + { + "name": "post_migration_token_supply", + "docs": [ + "post migration token supply" + ], + "type": "u64" + }, + { + "name": "migrated_collect_fee_mode", + "docs": [ + "migrated pool collect fee mode" + ], + "type": "u8" + }, + { + "name": "migrated_dynamic_fee", + "docs": [ + "migrated dynamic fee option." + ], + "type": "u8" + }, + { + "name": "migrated_pool_fee_bps", + "docs": [ + "migrated pool fee in bps" + ], + "type": "u16" + }, + { + "name": "_padding_1", + "docs": [ + "padding 1" + ], + "type": { + "array": [ + "u8", + 12 + ] + } + }, + { + "name": "_padding_2", + "docs": [ + "padding 2" + ], + "type": "u128" + }, + { + "name": "sqrt_start_price", + "docs": [ + "minimum price" + ], + "type": "u128" + }, + { + "name": "curve", + "docs": [ + "curve, only use 20 point firstly, we can extend that latter" + ], + "type": { + "array": [ + { + "defined": { + "name": "LiquidityDistributionConfig" + } + }, + 20 + ] + } + } + ] + } + }, + { + "name": "PoolFeeParameters", + "docs": [ + "Information regarding fee charges" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "base_fee", + "docs": [ + "Base fee" + ], + "type": { + "defined": { + "name": "BaseFeeParameters" + } + } + }, + { + "name": "dynamic_fee", + "docs": [ + "dynamic fee" + ], + "type": { + "option": { + "defined": { + "name": "DynamicFeeParameters" + } + } + } + } + ] + } + }, + { + "name": "PoolFees", + "docs": [ + "Information regarding fee charges" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "trade_fee_numerator", + "type": "u64" + }, + { + "name": "trade_fee_denominator", + "type": "u64" + }, + { + "name": "protocol_trade_fee_numerator", + "type": "u64" + }, + { + "name": "protocol_trade_fee_denominator", + "type": "u64" + } + ] + } + }, + { + "name": "PoolFeesConfig", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "base_fee", + "type": { + "defined": { + "name": "BaseFeeConfig" + } + } + }, + { + "name": "dynamic_fee", + "type": { + "defined": { + "name": "DynamicFeeConfig" + } + } + }, + { + "name": "padding_0", + "type": { + "array": [ + "u64", + 5 + ] + } + }, + { + "name": "padding_1", + "type": { + "array": [ + "u8", + 6 + ] + } + }, + { + "name": "protocol_fee_percent", + "type": "u8" + }, + { + "name": "referral_fee_percent", + "type": "u8" + } + ] + } + }, + { + "name": "PoolMetrics", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "total_protocol_base_fee", + "type": "u64" + }, + { + "name": "total_protocol_quote_fee", + "type": "u64" + }, + { + "name": "total_trading_base_fee", + "type": "u64" + }, + { + "name": "total_trading_quote_fee", + "type": "u64" + } + ] + } + }, + { + "name": "SwapParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount_in", + "type": "u64" + }, + { + "name": "minimum_amount_out", + "type": "u64" + } + ] + } + }, + { + "name": "SwapParameters2", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount_0", + "docs": [ + "When it's exact in, partial fill, this will be amount_in. When it's exact out, this will be amount_out" + ], + "type": "u64" + }, + { + "name": "amount_1", + "docs": [ + "When it's exact in, partial fill, this will be minimum_amount_out. When it's exact out, this will be maximum_amount_in" + ], + "type": "u64" + }, + { + "name": "swap_mode", + "docs": [ + "Swap mode, refer [SwapMode]" + ], + "type": "u8" + } + ] + } + }, + { + "name": "SwapResult", + "docs": [ + "Encodes all results of swapping" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "actual_input_amount", + "type": "u64" + }, + { + "name": "output_amount", + "type": "u64" + }, + { + "name": "next_sqrt_price", + "type": "u128" + }, + { + "name": "trading_fee", + "type": "u64" + }, + { + "name": "protocol_fee", + "type": "u64" + }, + { + "name": "referral_fee", + "type": "u64" + } + ] + } + }, + { + "name": "SwapResult2", + "type": { + "kind": "struct", + "fields": [ + { + "name": "included_fee_input_amount", + "type": "u64" + }, + { + "name": "excluded_fee_input_amount", + "type": "u64" + }, + { + "name": "amount_left", + "type": "u64" + }, + { + "name": "output_amount", + "type": "u64" + }, + { + "name": "next_sqrt_price", + "type": "u128" + }, + { + "name": "trading_fee", + "type": "u64" + }, + { + "name": "protocol_fee", + "type": "u64" + }, + { + "name": "referral_fee", + "type": "u64" + } + ] + } + }, + { + "name": "TokenSupplyParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pre_migration_token_supply", + "docs": [ + "pre migration token supply" + ], + "type": "u64" + }, + { + "name": "post_migration_token_supply", + "docs": [ + "post migration token supply", + "becase DBC allow user to swap over the migration quote threshold, so in extreme case user may swap more than allowed buffer on curve", + "that result the total supply in post migration may be increased a bit (between pre_migration_token_supply and post_migration_token_supply)" + ], + "type": "u64" + } + ] + } + }, + { + "name": "VirtualPool", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "volatility_tracker", + "docs": [ + "volatility tracker" + ], + "type": { + "defined": { + "name": "VolatilityTracker" + } + } + }, + { + "name": "config", + "docs": [ + "config key" + ], + "type": "pubkey" + }, + { + "name": "creator", + "docs": [ + "creator" + ], + "type": "pubkey" + }, + { + "name": "base_mint", + "docs": [ + "base mint" + ], + "type": "pubkey" + }, + { + "name": "base_vault", + "docs": [ + "base vault" + ], + "type": "pubkey" + }, + { + "name": "quote_vault", + "docs": [ + "quote vault" + ], + "type": "pubkey" + }, + { + "name": "base_reserve", + "docs": [ + "base reserve" + ], + "type": "u64" + }, + { + "name": "quote_reserve", + "docs": [ + "quote reserve" + ], + "type": "u64" + }, + { + "name": "protocol_base_fee", + "docs": [ + "protocol base fee" + ], + "type": "u64" + }, + { + "name": "protocol_quote_fee", + "docs": [ + "protocol quote fee" + ], + "type": "u64" + }, + { + "name": "partner_base_fee", + "docs": [ + "partner base fee" + ], + "type": "u64" + }, + { + "name": "partner_quote_fee", + "docs": [ + "trading quote fee" + ], + "type": "u64" + }, + { + "name": "sqrt_price", + "docs": [ + "current price" + ], + "type": "u128" + }, + { + "name": "activation_point", + "docs": [ + "Activation point" + ], + "type": "u64" + }, + { + "name": "pool_type", + "docs": [ + "pool type, spl token or token2022" + ], + "type": "u8" + }, + { + "name": "is_migrated", + "docs": [ + "is migrated" + ], + "type": "u8" + }, + { + "name": "is_partner_withdraw_surplus", + "docs": [ + "is partner withdraw surplus" + ], + "type": "u8" + }, + { + "name": "is_protocol_withdraw_surplus", + "docs": [ + "is protocol withdraw surplus" + ], + "type": "u8" + }, + { + "name": "migration_progress", + "docs": [ + "migration progress" + ], + "type": "u8" + }, + { + "name": "is_withdraw_leftover", + "docs": [ + "is withdraw leftover" + ], + "type": "u8" + }, + { + "name": "is_creator_withdraw_surplus", + "docs": [ + "is creator withdraw surplus" + ], + "type": "u8" + }, + { + "name": "migration_fee_withdraw_status", + "docs": [ + "migration fee withdraw status, first bit is for partner, second bit is for creator" + ], + "type": "u8" + }, + { + "name": "metrics", + "docs": [ + "pool metrics" + ], + "type": { + "defined": { + "name": "PoolMetrics" + } + } + }, + { + "name": "finish_curve_timestamp", + "docs": [ + "The time curve is finished" + ], + "type": "u64" + }, + { + "name": "creator_base_fee", + "docs": [ + "creator base fee" + ], + "type": "u64" + }, + { + "name": "creator_quote_fee", + "docs": [ + "creator quote fee" + ], + "type": "u64" + }, + { + "name": "_padding_1", + "docs": [ + "Padding for further use" + ], + "type": { + "array": [ + "u64", + 7 + ] + } + } + ] + } + }, + { + "name": "VirtualPoolMetadata", + "docs": [ + "Metadata for a virtual pool." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "virtual_pool", + "docs": [ + "virtual pool" + ], + "type": "pubkey" + }, + { + "name": "padding", + "docs": [ + "padding for future use" + ], + "type": { + "array": [ + "u128", + 6 + ] + } + }, + { + "name": "name", + "docs": [ + "Name of project." + ], + "type": "string" + }, + { + "name": "website", + "docs": [ + "Website of project." + ], + "type": "string" + }, + { + "name": "logo", + "docs": [ + "Logo of project" + ], + "type": "string" + } + ] + } + }, + { + "name": "VolatilityTracker", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "last_update_timestamp", + "type": "u64" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "sqrt_price_reference", + "type": "u128" + }, + { + "name": "volatility_accumulator", + "type": "u128" + }, + { + "name": "volatility_reference", + "type": "u128" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/libs/damm-v2/Cargo.toml b/libs/damm-v2/Cargo.toml new file mode 100644 index 0000000..7d39234 --- /dev/null +++ b/libs/damm-v2/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "damm-v2" +version = "0.1.3" +authors = [""] +edition = "2021" + +[dependencies] +anchor-lang = { workspace = true } +bytemuck = { workspace = true, features = ["min_const_generics"] } \ No newline at end of file diff --git a/libs/damm-v2/src/lib.rs b/libs/damm-v2/src/lib.rs new file mode 100644 index 0000000..7188651 --- /dev/null +++ b/libs/damm-v2/src/lib.rs @@ -0,0 +1,5 @@ +use anchor_lang::prelude::*; + +declare_program!(damm_v2); + +pub use damm_v2::*; diff --git a/libs/dynamic-bonding-curve/Cargo.toml b/libs/dynamic-bonding-curve/Cargo.toml new file mode 100644 index 0000000..9c6658c --- /dev/null +++ b/libs/dynamic-bonding-curve/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "dynamic-bonding-curve" +version = "0.1.6" +authors = [""] +edition = "2021" + +[dependencies] +anchor-lang = { workspace = true } +bytemuck = { workspace = true, features = ["min_const_generics"] } \ No newline at end of file diff --git a/libs/dynamic-bonding-curve/src/lib.rs b/libs/dynamic-bonding-curve/src/lib.rs new file mode 100644 index 0000000..e0cb6aa --- /dev/null +++ b/libs/dynamic-bonding-curve/src/lib.rs @@ -0,0 +1,5 @@ +use anchor_lang::prelude::*; + +declare_program!(dynamic_bonding_curve); + +pub use dynamic_bonding_curve::*; diff --git a/package-lock.json b/package-lock.json index 215ac80..5714c8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,8 @@ "@coral-xyz/anchor": "^0.31.1", "@solana/spl-token": "^0.4.13", "@solana/web3.js": "^1.98.2", - "litesvm": "^0.2.0" + "decimal.js": "^10.6.0", + "litesvm": "^0.1.0" }, "devDependencies": { "@types/bn.js": "^5.1.0", @@ -1009,6 +1010,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/decimal.js": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", + "license": "MIT" + }, "node_modules/deep-eql": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.4.tgz", @@ -1455,9 +1462,9 @@ } }, "node_modules/litesvm": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/litesvm/-/litesvm-0.2.0.tgz", - "integrity": "sha512-75+ZMkSFY5ynI3S+vCMnZv1wcILg5iNEj21B+XE/G3/P2dfTPj+rbdNM1q3eLFdlnXdewhiB4BLypKsBnQTSOw==", + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/litesvm/-/litesvm-0.1.0.tgz", + "integrity": "sha512-XfpvWgYxFQUZxwFzWJTsuHRc1y34q8WtC60lhvH1xb6YX1/RBLqzIClp2JkxtlqGnDi/WPlThsXGmC3SinuPMQ==", "license": "MIT", "dependencies": { "@solana/web3.js": "^1.68.0", @@ -1467,17 +1474,17 @@ "node": ">= 10" }, "optionalDependencies": { - "litesvm-darwin-arm64": "0.2.0", - "litesvm-darwin-universal": "0.2.0", - "litesvm-darwin-x64": "0.2.0", - "litesvm-linux-x64-gnu": "0.2.0", - "litesvm-linux-x64-musl": "0.2.0" + "litesvm-darwin-arm64": "0.1.0", + "litesvm-darwin-universal": "0.1.0", + "litesvm-darwin-x64": "0.1.0", + "litesvm-linux-x64-gnu": "0.1.0", + "litesvm-linux-x64-musl": "0.1.0" } }, "node_modules/litesvm-darwin-arm64": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/litesvm-darwin-arm64/-/litesvm-darwin-arm64-0.2.0.tgz", - "integrity": "sha512-fqGE7Z6iT+5Xob9o1xs0N7Tf3c1meJxDERf7Z6T7Loqm0seyUsfjM0gTOvMJHiWvvnOx+qIo/Cjhtp84Kb9v8w==", + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/litesvm-darwin-arm64/-/litesvm-darwin-arm64-0.1.0.tgz", + "integrity": "sha512-GwBph2fNaR9UP1nhFmQYk7UMcI9+ogrzpbDl2en70FUnPc+FDlchOts2X8IL5XFCU+m4ZGoQl/N9b+FywJN5lQ==", "cpu": [ "arm64" ], @@ -1491,9 +1498,9 @@ } }, "node_modules/litesvm-darwin-universal": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/litesvm-darwin-universal/-/litesvm-darwin-universal-0.2.0.tgz", - "integrity": "sha512-CNgVrQ9tknv8JbtpmOO0SNXuOQj769A3ufWHrMFEBuFhCr9CJ6RQI9a/HxPWjMHTC7EzlcF8klMupPYpqM8KGA==", + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/litesvm-darwin-universal/-/litesvm-darwin-universal-0.1.0.tgz", + "integrity": "sha512-GjGpz77ei+RfWiMtHiES0X8GP+TafFHWu5fAQXgXEoGia7RG32Z12iJBhwfvk0T4EKbm8bqlyqhe5Me/nARm/w==", "license": "MIT", "optional": true, "os": [ @@ -1504,9 +1511,9 @@ } }, "node_modules/litesvm-darwin-x64": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/litesvm-darwin-x64/-/litesvm-darwin-x64-0.2.0.tgz", - "integrity": "sha512-blRxD4y0FIx3E27Iv7oX0uz9x3v9KPD+++HLatBx5K5bh57qrAStUINsgT6MchYrxxOE0T2xktJaiSQSEMxWSA==", + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/litesvm-darwin-x64/-/litesvm-darwin-x64-0.1.0.tgz", + "integrity": "sha512-1N/IPfoT+gcpkvG9Wm7+vcaxgl/LB8hbm85cHDQRq4O1wyiRRiR6ByeNRamj+OFEDSfI7a/1NshhMobnnr2MGQ==", "cpu": [ "x64" ], @@ -1520,9 +1527,9 @@ } }, "node_modules/litesvm-linux-x64-gnu": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/litesvm-linux-x64-gnu/-/litesvm-linux-x64-gnu-0.2.0.tgz", - "integrity": "sha512-2PQcLvn5c8GLGPp/vLCFaladWe61wbtwwTlIMLEfPeU5f88jBPOaEryO85+0FHZS1awbT97caa55sFDpAO4CWw==", + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/litesvm-linux-x64-gnu/-/litesvm-linux-x64-gnu-0.1.0.tgz", + "integrity": "sha512-S6krvRz6BXxVZIkap5XkWwulSG4KsbFrxjyqP1X0zANa8jWMHEd09Zy9pPgfOetni2exg67fBmSlWq4sRfzlCw==", "cpu": [ "x64" ], @@ -1536,9 +1543,9 @@ } }, "node_modules/litesvm-linux-x64-musl": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/litesvm-linux-x64-musl/-/litesvm-linux-x64-musl-0.2.0.tgz", - "integrity": "sha512-9vAYFIicGjZIlwoCBii6yJmfIUVS4cdF0CxoAL+DGexTBLECk+Tr+WEFEXsvsYe4s81jxP04TTiUnasj/EaIcw==", + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/litesvm-linux-x64-musl/-/litesvm-linux-x64-musl-0.1.0.tgz", + "integrity": "sha512-3E9gC5HRCEHFsfUNDhAY9JKx6ou6JazlnYMhT89JgbAN/YsJmyEgkTfY6W7TVV90g4EAJ/K4smSmg+vV413mYQ==", "cpu": [ "x64" ], diff --git a/package.json b/package.json index 48f9fad..1cb4f73 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "@coral-xyz/anchor": "^0.31.1", "@solana/spl-token": "^0.4.13", "@solana/web3.js": "^1.98.2", - "litesvm": "^0.2.0" + "decimal.js": "^10.6.0", + "litesvm": "^0.1.0" }, "devDependencies": { "@types/bn.js": "^5.1.0", diff --git a/programs/dynamic-fee-sharing/Cargo.toml b/programs/dynamic-fee-sharing/Cargo.toml index ae9831d..b7d7eed 100644 --- a/programs/dynamic-fee-sharing/Cargo.toml +++ b/programs/dynamic-fee-sharing/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dynamic-fee-sharing" -version = "0.1.0" +version = "0.1.1" description = "Created with Anchor" edition = "2021" @@ -18,12 +18,15 @@ idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"] [dependencies] -anchor-lang = {version = "0.31.1", features = ["event-cpi"]} -anchor-spl = "0.31.1" -bytemuck = { version = "1.20.0", features = ["derive", "min_const_generics"] } +anchor-lang = { workspace = true } +anchor-spl = { workspace = true } +bytemuck = { workspace = true } num_enum = "0.7.0" ruint = "1.3.0" static_assertions = "1.1.0" +const-crypto = "0.3.0" +damm-v2 = { path = "../../libs/damm-v2" } +dynamic-bonding-curve = { path = "../../libs/dynamic-bonding-curve" } [dev-dependencies] proptest = "1.2.0" \ No newline at end of file diff --git a/programs/dynamic-fee-sharing/src/const_pda.rs b/programs/dynamic-fee-sharing/src/const_pda.rs new file mode 100644 index 0000000..c502e41 --- /dev/null +++ b/programs/dynamic-fee-sharing/src/const_pda.rs @@ -0,0 +1,31 @@ +use anchor_lang::solana_program::pubkey::Pubkey; +use const_crypto::ed25519; + +pub mod fee_vault_authority { + use super::*; + + const FEE_VAULT_AUTHORITY_AND_BUMP: ([u8; 32], u8) = ed25519::derive_program_address( + &[crate::constants::seeds::FEE_VAULT_AUTHORITY_PREFIX], + &crate::ID_CONST.to_bytes(), + ); + + pub const ID: Pubkey = Pubkey::new_from_array(FEE_VAULT_AUTHORITY_AND_BUMP.0); + pub const BUMP: u8 = FEE_VAULT_AUTHORITY_AND_BUMP.1; +} + +// Potential optimization on event authority too since anchor internally do Pubkey::find_program_address during runtime. + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_const_fee_vault_authority() { + let (derived_pool_authority, derived_bump) = Pubkey::find_program_address( + &[crate::constants::seeds::FEE_VAULT_AUTHORITY_PREFIX], + &crate::ID, + ); + assert_eq!(fee_vault_authority::ID, derived_pool_authority); + assert_eq!(fee_vault_authority::BUMP, derived_bump); + } +} diff --git a/programs/dynamic-fee-sharing/src/constants.rs b/programs/dynamic-fee-sharing/src/constants.rs index b91845d..016fb70 100644 --- a/programs/dynamic-fee-sharing/src/constants.rs +++ b/programs/dynamic-fee-sharing/src/constants.rs @@ -1,3 +1,6 @@ +use anchor_lang::prelude::Pubkey; +use anchor_lang::Discriminator; + pub const MAX_USER: usize = 5; pub const PRECISION_SCALE: u8 = 64; @@ -6,3 +9,45 @@ pub mod seeds { pub const FEE_VAULT_AUTHORITY_PREFIX: &[u8] = b"fee_vault_authority"; pub const TOKEN_VAULT_PREFIX: &[u8] = b"token_vault"; } + +// (program_id, instruction, index_of_token_vault_account) +// TODO should find a way to avoid hardcoding index of token_vault_account +pub static WHITELISTED_ACTIONS: [(Pubkey, &[u8], usize); 7] = [ + // damm v2 + ( + damm_v2::ID, + damm_v2::client::args::ClaimPositionFee::DISCRIMINATOR, + 4, + ), + ( + damm_v2::ID, + damm_v2::client::args::ClaimReward::DISCRIMINATOR, + 5, + ), + // DBC + ( + dynamic_bonding_curve::ID, + dynamic_bonding_curve::client::args::CreatorWithdrawSurplus::DISCRIMINATOR, + 3, + ), + ( + dynamic_bonding_curve::ID, + dynamic_bonding_curve::client::args::ClaimCreatorTradingFee::DISCRIMINATOR, + 3, + ), + ( + dynamic_bonding_curve::ID, + dynamic_bonding_curve::client::args::PartnerWithdrawSurplus::DISCRIMINATOR, + 3, + ), + ( + dynamic_bonding_curve::ID, + dynamic_bonding_curve::client::args::ClaimTradingFee::DISCRIMINATOR, + 4, + ), + ( + dynamic_bonding_curve::ID, + dynamic_bonding_curve::client::args::WithdrawMigrationFee::DISCRIMINATOR, + 3, + ), +]; diff --git a/programs/dynamic-fee-sharing/src/error.rs b/programs/dynamic-fee-sharing/src/error.rs index 8e12aa6..06f8d0e 100644 --- a/programs/dynamic-fee-sharing/src/error.rs +++ b/programs/dynamic-fee-sharing/src/error.rs @@ -25,4 +25,13 @@ pub enum FeeVaultError { #[msg("Exceeded number of users allowed")] ExceededUser, + + #[msg("Invalid fee vault")] + InvalidFeeVault, + + #[msg("Invalid signer")] + InvalidSigner, + + #[msg("Invalid action")] + InvalidAction, } diff --git a/programs/dynamic-fee-sharing/src/event.rs b/programs/dynamic-fee-sharing/src/event.rs index d1aa625..b75bde8 100644 --- a/programs/dynamic-fee-sharing/src/event.rs +++ b/programs/dynamic-fee-sharing/src/event.rs @@ -13,11 +13,11 @@ pub struct EvtInitializeFeeVault { #[event] pub struct EvtFundFee { + pub source_program: Pubkey, pub fee_vault: Pubkey, - pub funder: Pubkey, - pub excluded_transfer_fee_amount: u64, - pub max_amount: u64, + pub funded_amount: u64, pub fee_per_share: u128, + pub payload: Vec, } #[event] diff --git a/programs/dynamic-fee-sharing/src/instructions/ix_claim_fee.rs b/programs/dynamic-fee-sharing/src/instructions/ix_claim_fee.rs index 73a6622..f7fa3c9 100644 --- a/programs/dynamic-fee-sharing/src/instructions/ix_claim_fee.rs +++ b/programs/dynamic-fee-sharing/src/instructions/ix_claim_fee.rs @@ -1,7 +1,7 @@ use anchor_lang::prelude::*; use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface}; -use crate::constants::seeds::FEE_VAULT_AUTHORITY_PREFIX; +use crate::const_pda; use crate::event::EvtClaimFee; use crate::state::FeeVault; use crate::utils::token::transfer_from_fee_vault; @@ -12,13 +12,10 @@ pub struct ClaimFeeCtx<'info> { #[account(mut, has_one = token_vault, has_one = token_mint)] pub fee_vault: AccountLoader<'info, FeeVault>, - /// CHECK: pool authority + /// CHECK: fee vault authority #[account( - seeds = [ - FEE_VAULT_AUTHORITY_PREFIX.as_ref(), - ], - bump, - )] + address = const_pda::fee_vault_authority::ID + )] pub fee_vault_authority: UncheckedAccount<'info>, #[account(mut)] @@ -46,7 +43,6 @@ pub fn handle_claim_fee(ctx: Context, index: u8) -> Result<()> { &ctx.accounts.user_token_vault, &ctx.accounts.token_program, fee_being_claimed, - ctx.bumps.fee_vault_authority, )?; emit_cpi!(EvtClaimFee { diff --git a/programs/dynamic-fee-sharing/src/instructions/ix_fund_by_claiming_fee.rs b/programs/dynamic-fee-sharing/src/instructions/ix_fund_by_claiming_fee.rs new file mode 100644 index 0000000..4011750 --- /dev/null +++ b/programs/dynamic-fee-sharing/src/instructions/ix_fund_by_claiming_fee.rs @@ -0,0 +1,125 @@ +use crate::constants::WHITELISTED_ACTIONS; +use crate::event::EvtFundFee; +use crate::state::FeeVault; +use crate::{error::FeeVaultError, math::SafeMath}; +use anchor_lang::prelude::*; +use anchor_lang::solana_program::{instruction::Instruction, program::invoke_signed}; +use anchor_spl::token_interface::TokenAccount; + +#[event_cpi] +#[derive(Accounts)] +pub struct FundByClaimingFeeCtx<'info> { + #[account(mut, has_one = token_vault)] + pub fee_vault: AccountLoader<'info, FeeVault>, + + #[account(mut)] + pub token_vault: Box>, + + /// signer + pub signer: Signer<'info>, + + /// CHECK:: source program + pub source_program: UncheckedAccount<'info>, +} + +pub fn is_support_action<'info>( + source_program: &Pubkey, + discriminator: &[u8], + token_vault: Pubkey, + remaining_accounts: &[AccountInfo<'info>], +) -> bool { + for &(program, disc, token_vault_index) in WHITELISTED_ACTIONS.iter() { + if program.eq(source_program) && disc.eq(discriminator) { + if let Some(token_vault_account) = remaining_accounts.get(token_vault_index) { + return token_vault.eq(token_vault_account.key); + } + } + } + false +} + +pub fn handle_fund_by_claiming_fee( + ctx: Context, + payload: Vec, +) -> Result<()> { + let discriminator = &payload[..8]; // first 8 bytes is discriminator + require!( + is_support_action( + ctx.accounts.source_program.key, + discriminator, + ctx.accounts.token_vault.key(), + ctx.remaining_accounts + ), + FeeVaultError::InvalidAction + ); + + let fee_vault = ctx.accounts.fee_vault.load()?; + + require!( + fee_vault.is_share_holder(ctx.accounts.signer.key), + FeeVaultError::InvalidSigner + ); + + // support fee vault type is pda account + require!( + fee_vault.fee_vault_type == 1, + FeeVaultError::InvalidFeeVault + ); + + let before_token_vault_balance = ctx.accounts.token_vault.amount; + + let accounts: Vec = ctx + .remaining_accounts + .iter() + .map(|acc| { + let is_signer = acc.key == &ctx.accounts.fee_vault.key(); + AccountMeta { + pubkey: *acc.key, + is_signer: is_signer, + is_writable: acc.is_writable, + } + }) + .collect(); + + let account_infos: Vec = ctx + .remaining_accounts + .iter() + .map(|acc| AccountInfo { ..acc.clone() }) + .collect(); + // invoke instruction to amm + let base = fee_vault.base; + let token_mint = fee_vault.token_mint; + let fee_vault_bump = fee_vault.fee_vault_bump; + let signer_seeds = fee_vault_seeds!(base, token_mint, fee_vault_bump); + drop(fee_vault); + + invoke_signed( + &Instruction { + program_id: ctx.accounts.source_program.key(), + accounts, + data: payload.clone(), + }, + &account_infos, + &[signer_seeds], + )?; + + ctx.accounts.token_vault.reload()?; + + let after_token_vault_balance = ctx.accounts.token_vault.amount; + + let claimed_amount = after_token_vault_balance.safe_sub(before_token_vault_balance)?; + + if claimed_amount > 0 { + let mut fee_vault = ctx.accounts.fee_vault.load_mut()?; + fee_vault.fund_fee(claimed_amount)?; + + emit_cpi!(EvtFundFee { + source_program: ctx.accounts.source_program.key(), + fee_vault: ctx.accounts.fee_vault.key(), + payload, + funded_amount: claimed_amount, + fee_per_share: fee_vault.fee_per_share, + }); + } + Ok(()) +} diff --git a/programs/dynamic-fee-sharing/src/instructions/ix_fund_fee.rs b/programs/dynamic-fee-sharing/src/instructions/ix_fund_fee.rs index 0ef97a5..df2695e 100644 --- a/programs/dynamic-fee-sharing/src/instructions/ix_fund_fee.rs +++ b/programs/dynamic-fee-sharing/src/instructions/ix_fund_fee.rs @@ -46,11 +46,11 @@ pub fn handle_fund_fee(ctx: Context, max_amount: u64) -> Result<()> )?; emit_cpi!(EvtFundFee { + source_program: Pubkey::default(), fee_vault: ctx.accounts.fee_vault.key(), - funder: ctx.accounts.funder.key(), - fee_per_share: fee_vault.fee_per_share, - excluded_transfer_fee_amount, - max_amount + payload: vec![], + funded_amount: excluded_transfer_fee_amount, + fee_per_share: fee_vault.fee_per_share }); Ok(()) diff --git a/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault.rs b/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault.rs index a14b925..dadd994 100644 --- a/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault.rs +++ b/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault.rs @@ -1,6 +1,7 @@ use crate::constants::MAX_USER; use crate::error::FeeVaultError; use crate::event::EvtInitializeFeeVault; +use crate::state::FeeVaultType; use crate::utils::token::{get_token_program_flags, is_supported_mint}; use crate::{ constants::seeds::{FEE_VAULT_AUTHORITY_PREFIX, TOKEN_VAULT_PREFIX}, @@ -104,6 +105,9 @@ pub fn handle_initialize_fee_vault( &ctx.accounts.fee_vault, ctx.accounts.owner.key, &ctx.accounts.token_vault.key(), + &Pubkey::default(), + 0, + FeeVaultType::NonPdaAccount.into(), )?; emit_cpi!(EvtInitializeFeeVault { @@ -123,6 +127,9 @@ pub fn create_fee_vault<'info>( fee_vault: &AccountLoader<'info, FeeVault>, owner: &Pubkey, token_vault: &Pubkey, + base: &Pubkey, + fee_vault_bump: u8, + fee_vault_type: u8, ) -> Result<()> { require!(is_supported_mint(&token_mint)?, FeeVaultError::InvalidMint); @@ -134,6 +141,9 @@ pub fn create_fee_vault<'info>( get_token_program_flags(&token_mint).into(), &token_mint.key(), token_vault, + base, + fee_vault_bump, + fee_vault_type, ¶ms.users, )?; Ok(()) diff --git a/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault_pda.rs b/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault_pda.rs index c7d3227..0a34e98 100644 --- a/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault_pda.rs +++ b/programs/dynamic-fee-sharing/src/instructions/ix_initialize_fee_vault_pda.rs @@ -1,5 +1,6 @@ use crate::constants::seeds::FEE_VAULT_PREFIX; use crate::event::EvtInitializeFeeVault; +use crate::state::FeeVaultType; use crate::{ constants::seeds::{FEE_VAULT_AUTHORITY_PREFIX, TOKEN_VAULT_PREFIX}, state::FeeVault, @@ -76,6 +77,9 @@ pub fn handle_initialize_fee_vault_pda( &ctx.accounts.fee_vault, ctx.accounts.owner.key, &ctx.accounts.token_vault.key(), + &ctx.accounts.base.key, + ctx.bumps.fee_vault, + FeeVaultType::PdaAccount.into(), )?; emit_cpi!(EvtInitializeFeeVault { diff --git a/programs/dynamic-fee-sharing/src/instructions/mod.rs b/programs/dynamic-fee-sharing/src/instructions/mod.rs index f1bc8dc..44af05a 100644 --- a/programs/dynamic-fee-sharing/src/instructions/mod.rs +++ b/programs/dynamic-fee-sharing/src/instructions/mod.rs @@ -6,3 +6,5 @@ pub mod ix_claim_fee; pub use ix_claim_fee::*; pub mod ix_initialize_fee_vault_pda; pub use ix_initialize_fee_vault_pda::*; +pub mod ix_fund_by_claiming_fee; +pub use ix_fund_by_claiming_fee::*; diff --git a/programs/dynamic-fee-sharing/src/lib.rs b/programs/dynamic-fee-sharing/src/lib.rs index 8bd8188..2a887bd 100644 --- a/programs/dynamic-fee-sharing/src/lib.rs +++ b/programs/dynamic-fee-sharing/src/lib.rs @@ -7,6 +7,7 @@ pub mod constants; pub mod error; pub mod instructions; pub use instructions::*; +pub mod const_pda; pub mod event; pub mod math; pub mod state; @@ -36,6 +37,13 @@ pub mod dynamic_fee_sharing { instructions::handle_fund_fee(ctx, max_amount) } + pub fn fund_by_claiming_fee( + ctx: Context, + payload: Vec, + ) -> Result<()> { + instructions::handle_fund_by_claiming_fee(ctx, payload) + } + pub fn claim_fee(ctx: Context, index: u8) -> Result<()> { instructions::handle_claim_fee(ctx, index) } diff --git a/programs/dynamic-fee-sharing/src/macros.rs b/programs/dynamic-fee-sharing/src/macros.rs index f386009..5dcfce3 100644 --- a/programs/dynamic-fee-sharing/src/macros.rs +++ b/programs/dynamic-fee-sharing/src/macros.rs @@ -1,6 +1,19 @@ -//! Macro functions macro_rules! fee_vault_authority_seeds { - ($bump:expr) => { - &[b"fee_vault_authority".as_ref(), &[$bump]] + () => { + &[ + crate::constants::seeds::FEE_VAULT_AUTHORITY_PREFIX, + &[crate::const_pda::fee_vault_authority::BUMP], + ] + }; +} + +macro_rules! fee_vault_seeds { + ($base:expr, $token_mint:expr, $bump:expr) => { + &[ + crate::constants::seeds::FEE_VAULT_PREFIX, + $base.as_ref(), + $token_mint.as_ref(), + &[$bump], + ] }; } diff --git a/programs/dynamic-fee-sharing/src/state/fee_vault.rs b/programs/dynamic-fee-sharing/src/state/fee_vault.rs index db1a8b6..a9c9519 100644 --- a/programs/dynamic-fee-sharing/src/state/fee_vault.rs +++ b/programs/dynamic-fee-sharing/src/state/fee_vault.rs @@ -5,8 +5,25 @@ use crate::{ math::{mul_shr, shl_div, SafeMath}, }; use anchor_lang::prelude::*; +use num_enum::{IntoPrimitive, TryFromPrimitive}; use static_assertions::const_assert_eq; +#[repr(u8)] +#[derive( + Clone, + Copy, + Debug, + PartialEq, + IntoPrimitive, + TryFromPrimitive, + AnchorDeserialize, + AnchorSerialize, +)] +pub enum FeeVaultType { + NonPdaAccount, + PdaAccount, +} + #[account(zero_copy)] #[derive(InitSpace, Debug, Default)] pub struct FeeVault { @@ -14,12 +31,15 @@ pub struct FeeVault { pub token_mint: Pubkey, pub token_vault: Pubkey, pub token_flag: u8, // indicate whether token is spl-token or token2022 - pub padding_0: [u8; 15], + pub fee_vault_type: u8, + pub fee_vault_bump: u8, + pub padding_0: [u8; 13], pub total_share: u32, pub padding_1: [u8; 4], pub total_funded_fee: u64, pub fee_per_share: u128, - pub padding: [u128; 6], + pub base: Pubkey, + pub padding: [u128; 4], pub users: [UserFee; MAX_USER], } const_assert_eq!(FeeVault::INIT_SPACE, 640); @@ -43,6 +63,9 @@ impl FeeVault { token_flag: u8, token_mint: &Pubkey, token_vault: &Pubkey, + base: &Pubkey, + fee_vault_bump: u8, + fee_vault_type: u8, users: &[UserShare], ) -> Result<()> { self.owner = *owner; @@ -59,6 +82,10 @@ impl FeeVault { total_share = total_share.safe_add(users[i].share)?; } self.total_share = total_share; + self.base = *base; + self.fee_vault_bump = fee_vault_bump; + self.fee_vault_type = fee_vault_type; + Ok(()) } @@ -92,4 +119,10 @@ impl FeeVault { Ok(fee_being_claimed) } + + pub fn is_share_holder(&self, signer: &Pubkey) -> bool { + self.users + .iter() + .any(|share_holder| share_holder.address.eq(signer)) + } } diff --git a/programs/dynamic-fee-sharing/src/utils/token.rs b/programs/dynamic-fee-sharing/src/utils/token.rs index 19ec28a..65787c0 100644 --- a/programs/dynamic-fee-sharing/src/utils/token.rs +++ b/programs/dynamic-fee-sharing/src/utils/token.rs @@ -144,9 +144,8 @@ pub fn transfer_from_fee_vault<'c: 'info, 'info>( token_owner_account: &InterfaceAccount<'info, TokenAccount>, token_program: &Interface<'info, TokenInterface>, amount: u64, - bump: u8, ) -> Result<()> { - let signer_seeds = fee_vault_authority_seeds!(bump); + let signer_seeds = fee_vault_authority_seeds!(); let instruction = spl_token_2022::instruction::transfer_checked( token_program.key, diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..552d6d6 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.85.0" \ No newline at end of file diff --git a/tests/claim_damm_v2.test.ts b/tests/claim_damm_v2.test.ts new file mode 100644 index 0000000..54785da --- /dev/null +++ b/tests/claim_damm_v2.test.ts @@ -0,0 +1,207 @@ +import { LiteSVM } from "litesvm"; +import { PublicKey, Keypair, Transaction } from "@solana/web3.js"; +import { + generateUsers, + getTokenBalance, + sendTransactionOrExpectThrowError, + startSvm, + warpToTimestamp, +} from "./common/svm"; +import { + createToken, + getFeeVault, + mintToken, +} from "./common"; +import { createDammV2Pool, dammV2Swap, initializeAndFundReward } from "./common/damm_v2"; +import { claimDammV2Fee, claimDammV2Reward, createFeeVaultPda } from "./common/dfs"; +import { BN } from "bn.js"; +import { expect } from "chai"; +import { + AuthorityType, + createSetAuthorityInstruction, + TOKEN_2022_PROGRAM_ID, +} from "@solana/spl-token"; + +describe("Fund by claiming damm v2", () => { + let svm: LiteSVM; + let admin: Keypair; + let creator: Keypair; + let vaultOwner: Keypair; + let tokenAMint: PublicKey; + let tokenBMint: PublicKey; + let rewardMint: PublicKey; + let dammV2Pool: PublicKey; + let positionNftAccount: PublicKey; + let position: PublicKey; + let shareHolder: Keypair; + + beforeEach(async () => { + svm = startSvm(); + [admin, creator, vaultOwner, shareHolder] = generateUsers(svm, 4); + tokenAMint = createToken(svm, admin, admin.publicKey, null); + tokenBMint = createToken(svm, admin, admin.publicKey, null); + rewardMint = createToken(svm, admin, admin.publicKey, null); + + mintToken(svm, admin, tokenAMint, admin, creator.publicKey); + mintToken(svm, admin, tokenBMint, admin, creator.publicKey); + mintToken(svm, admin, rewardMint, admin, creator.publicKey); + + // create damm v2 pool + const createDmmV2PoolRes = await createDammV2Pool( + svm, + creator, + tokenAMint, + tokenBMint + ); + dammV2Pool = createDmmV2PoolRes.pool; + position = createDmmV2PoolRes.position; + positionNftAccount = createDmmV2PoolRes.positionNftAccount; + }); + + it("Fund by claim damm v2 position fee", async () => { + const { feeVault, tokenVault } = await createFeeVaultPda( + svm, + admin, + vaultOwner.publicKey, + tokenBMint, + { + padding: [], + users: [ + { + address: shareHolder.publicKey, + share: 100, + }, + { + address: PublicKey.unique(), + share: 100, + }, + ], + } + ); + + const setAuthorityIx = createSetAuthorityInstruction( + positionNftAccount, + creator.publicKey, + AuthorityType.AccountOwner, + feeVault, + [], + TOKEN_2022_PROGRAM_ID + ); + const assignOwnerTx = new Transaction().add(setAuthorityIx); + assignOwnerTx.recentBlockhash = svm.latestBlockhash(); + assignOwnerTx.sign(creator); + + sendTransactionOrExpectThrowError(svm, assignOwnerTx); + + let vaultState = getFeeVault(svm, feeVault); + + const preTotalFundedFee = vaultState.totalFundedFee; + const preFeePerShare = vaultState.feePerShare; + + const preTokenVaultBalance = getTokenBalance(svm, tokenVault); + + // swap damm v2 + await dammV2Swap(svm, { + payer: creator, + pool: dammV2Pool, + inputTokenMint: tokenAMint, + outputTokenMint: tokenBMint, + amountIn: new BN(10000 * 10 ** 6), + minimumAmountOut: new BN(0), + }); + + await claimDammV2Fee( + svm, + shareHolder, + creator, + feeVault, + tokenVault, + dammV2Pool, + position, + positionNftAccount + ); + + const postTokenVaultBalance = getTokenBalance(svm, tokenVault); + vaultState = getFeeVault(svm, feeVault); + + const postTotalFundedFee = vaultState.totalFundedFee; + const postFeePerShare = vaultState.feePerShare; + + expect(postTotalFundedFee.sub(preTotalFundedFee).toString()).eq( + postTokenVaultBalance.sub(preTokenVaultBalance).toString() + ); + expect(Number(postFeePerShare.sub(preFeePerShare))).gt(0); + }); + + + it("Fund by claiming damm v2 reward", async () => { + const { feeVault, tokenVault } = await createFeeVaultPda( + svm, + admin, + vaultOwner.publicKey, + rewardMint, + { + padding: [], + users: [ + { + address: shareHolder.publicKey, + share: 100, + }, + { + address: PublicKey.unique(), + share: 100, + }, + ], + } + ); + + const setAuthorityIx = createSetAuthorityInstruction( + positionNftAccount, + creator.publicKey, + AuthorityType.AccountOwner, + feeVault, + [], + TOKEN_2022_PROGRAM_ID + ); + const assignOwnerTx = new Transaction().add(setAuthorityIx); + assignOwnerTx.recentBlockhash = svm.latestBlockhash(); + assignOwnerTx.sign(creator); + + sendTransactionOrExpectThrowError(svm, assignOwnerTx); + + let vaultState = getFeeVault(svm, feeVault); + + const preTotalFundedFee = vaultState.totalFundedFee; + const preFeePerShare = vaultState.feePerShare; + + const preTokenVaultBalance = getTokenBalance(svm, tokenVault); + + const rewardIndex = 0; + await initializeAndFundReward(svm, creator, dammV2Pool, rewardMint, rewardIndex); + + warpToTimestamp(svm, new BN(12 * 60 * 60)); + + await claimDammV2Reward( + svm, + shareHolder, + creator, + feeVault, + tokenVault, + dammV2Pool, + position, + positionNftAccount, + rewardIndex + ); + + const postTokenVaultBalance = getTokenBalance(svm, tokenVault); + vaultState = getFeeVault(svm, feeVault); + + const postTotalFundedFee = vaultState.totalFundedFee; + const postFeePerShare = vaultState.feePerShare; + + expect(postTotalFundedFee.sub(preTotalFundedFee).toString()).eq( + postTokenVaultBalance.sub(preTokenVaultBalance).toString() + ); + expect(Number(postFeePerShare.sub(preFeePerShare))).gt(0); + }); +}); diff --git a/tests/claim_dbc_creator_trading_fee.test.ts b/tests/claim_dbc_creator_trading_fee.test.ts new file mode 100644 index 0000000..30645be --- /dev/null +++ b/tests/claim_dbc_creator_trading_fee.test.ts @@ -0,0 +1,411 @@ +import { BN } from "bn.js"; +import { Keypair, PublicKey } from "@solana/web3.js"; +import { expect } from "chai"; +import { LiteSVM } from "litesvm"; +import { generateUsers, getTokenBalance, startSvm } from "./common/svm"; +import { + createToken, + getFeeVault, + mintToken, +} from "./common"; +import { + buildDefaultCurve, + createConfig, + CreateConfigParams, + createVirtualPool, + getVirtualConfigState, + getVirtualPoolState, + swap, + SwapParams, + transferCreator, +} from "./common/dbc"; +import { + claimDbcCreatorTradingFee, + claimDbcPartnerTradingFee, + createFeeVaultPda, + withdrawDbcCreatorSurplus, + withdrawDbcPartnerSurplus, + withdrawMigrationFee, +} from "./common/dfs"; + +describe("Funding by claiming in DBC", () => { + let svm: LiteSVM; + let admin: Keypair; + let payer: Keypair; + let user: Keypair; + let poolCreator: Keypair; + let vaultOwner: Keypair; + let quoteMint: PublicKey; + let shareHolder: Keypair; + + beforeEach(async () => { + svm = startSvm(); + admin = Keypair.generate(); + payer = Keypair.generate(); + user = Keypair.generate(); + poolCreator = Keypair.generate(); + [admin, payer, user, poolCreator, vaultOwner, shareHolder] = generateUsers(svm, 6); + quoteMint = createToken(svm, admin, admin.publicKey, null); + }); + + it("claim dbc creator trading fee", async () => { + const { feeVault, tokenVault } = await createFeeVaultPda( + svm, + admin, + vaultOwner.publicKey, + quoteMint, + { + padding: [], + users: [ + { + address: shareHolder.publicKey, + share: 100, + }, + { + address: PublicKey.unique(), + share: 100, + }, + ], + } + ); + + const { virtualPool, virtualPoolConfig } = await setupPool( + svm, + admin, + user, + poolCreator, + payer, + feeVault, + quoteMint + ); + + let vaultState = getFeeVault(svm, feeVault); + + const preTotalFundedFee = vaultState.totalFundedFee; + const preFeePerShare = vaultState.feePerShare; + + const preTokenVaultBalance = getTokenBalance(svm, tokenVault); + + await claimDbcCreatorTradingFee( + svm, + shareHolder, + feeVault, + tokenVault, + virtualPoolConfig, + virtualPool + ); + + const postTokenVaultBalance = getTokenBalance(svm, tokenVault); + vaultState = getFeeVault(svm, feeVault); + + const postTotalFundedFee = vaultState.totalFundedFee; + const postFeePerShare = vaultState.feePerShare; + + expect(postTotalFundedFee.sub(preTotalFundedFee).toString()).eq( + postTokenVaultBalance.sub(preTokenVaultBalance).toString() + ); + expect(Number(postFeePerShare.sub(preFeePerShare))).gt(0); + }); + + it("claim dbc partner trading fee", async () => { + const { feeVault, tokenVault } = await createFeeVaultPda( + svm, + admin, + vaultOwner.publicKey, + quoteMint, + { + padding: [], + users: [ + { + address: shareHolder.publicKey, + share: 100, + }, + { + address: PublicKey.unique(), + share: 100, + }, + ], + } + ); + + const { virtualPool, virtualPoolConfig } = await setupPool( + svm, + admin, + user, + poolCreator, + payer, + feeVault, + quoteMint + ); + + let vaultState = getFeeVault(svm, feeVault); + + const preTotalFundedFee = vaultState.totalFundedFee; + const preFeePerShare = vaultState.feePerShare; + + const preTokenVaultBalance = getTokenBalance(svm, tokenVault); + + await claimDbcPartnerTradingFee( + svm, + shareHolder, + payer, + feeVault, + tokenVault, + virtualPoolConfig, + virtualPool + ); + + const postTokenVaultBalance = getTokenBalance(svm, tokenVault); + vaultState = getFeeVault(svm, feeVault); + + const postTotalFundedFee = vaultState.totalFundedFee; + const postFeePerShare = vaultState.feePerShare; + + expect(postTotalFundedFee.sub(preTotalFundedFee).toString()).eq( + postTokenVaultBalance.sub(preTokenVaultBalance).toString() + ); + expect(Number(postFeePerShare.sub(preFeePerShare))).gt(0); + }); + + it("withdraw dbc creator surplus", async () => { + const { feeVault, tokenVault } = await createFeeVaultPda( + svm, + admin, + vaultOwner.publicKey, + quoteMint, + { + padding: [], + users: [ + { + address: shareHolder.publicKey, + share: 100, + }, + { + address: PublicKey.unique(), + share: 100, + }, + ], + } + ); + + const { virtualPool, virtualPoolConfig } = await setupPool( + svm, + admin, + user, + poolCreator, + payer, + feeVault, + quoteMint + ); + + let vaultState = getFeeVault(svm, feeVault); + + const preTotalFundedFee = vaultState.totalFundedFee; + const preFeePerShare = vaultState.feePerShare; + + const preTokenVaultBalance = getTokenBalance(svm, tokenVault); + + await withdrawDbcCreatorSurplus( + svm, + shareHolder, + feeVault, + tokenVault, + virtualPoolConfig, + virtualPool + ); + + const postTokenVaultBalance = getTokenBalance(svm, tokenVault); + vaultState = getFeeVault(svm, feeVault); + + const postTotalFundedFee = vaultState.totalFundedFee; + const postFeePerShare = vaultState.feePerShare; + + expect(postTotalFundedFee.sub(preTotalFundedFee).toString()).eq( + postTokenVaultBalance.sub(preTokenVaultBalance).toString() + ); + expect(Number(postFeePerShare.sub(preFeePerShare))).gt(0); + }); + + it("withdraw dbc partner surplus", async () => { + const { feeVault, tokenVault } = await createFeeVaultPda( + svm, + admin, + vaultOwner.publicKey, + quoteMint, + { + padding: [], + users: [ + { + address: shareHolder.publicKey, + share: 100, + }, + { + address: PublicKey.unique(), + share: 100, + }, + ], + } + ); + + const { virtualPool, virtualPoolConfig } = await setupPool( + svm, + admin, + user, + poolCreator, + payer, + feeVault, + quoteMint + ); + + let vaultState = getFeeVault(svm, feeVault); + + const preTotalFundedFee = vaultState.totalFundedFee; + const preFeePerShare = vaultState.feePerShare; + + const preTokenVaultBalance = getTokenBalance(svm, tokenVault); + + await withdrawDbcPartnerSurplus( + svm, + shareHolder, + feeVault, + tokenVault, + virtualPoolConfig, + virtualPool + ); + + const postTokenVaultBalance = getTokenBalance(svm, tokenVault); + vaultState = getFeeVault(svm, feeVault); + + const postTotalFundedFee = vaultState.totalFundedFee; + const postFeePerShare = vaultState.feePerShare; + + expect(postTotalFundedFee.sub(preTotalFundedFee).toString()).eq( + postTokenVaultBalance.sub(preTokenVaultBalance).toString() + ); + expect(Number(postFeePerShare.sub(preFeePerShare))).gt(0); + }); + + it("withdraw migration fee", async () => { + const { feeVault, tokenVault } = await createFeeVaultPda( + svm, + admin, + vaultOwner.publicKey, + quoteMint, + { + padding: [], + users: [ + { + address: shareHolder.publicKey, + share: 100, + }, + { + address: PublicKey.unique(), + share: 100, + }, + ], + } + ); + + const { virtualPool, virtualPoolConfig } = await setupPool( + svm, + admin, + user, + poolCreator, + payer, + feeVault, + quoteMint + ); + + let vaultState = getFeeVault(svm, feeVault); + + const preTotalFundedFee = vaultState.totalFundedFee; + const preFeePerShare = vaultState.feePerShare; + + const preTokenVaultBalance = getTokenBalance(svm, tokenVault); + + await withdrawMigrationFee( + svm, + shareHolder, + feeVault, + tokenVault, + virtualPoolConfig, + virtualPool, + 0 + ); + + const postTokenVaultBalance = getTokenBalance(svm, tokenVault); + vaultState = getFeeVault(svm, feeVault); + + const postTotalFundedFee = vaultState.totalFundedFee; + const postFeePerShare = vaultState.feePerShare; + + expect(postTotalFundedFee.sub(preTotalFundedFee).toString()).eq( + postTokenVaultBalance.sub(preTokenVaultBalance).toString() + ); + expect(Number(postFeePerShare.sub(preFeePerShare))).gt(0); + }); +}); + +async function setupPool( + svm: LiteSVM, + admin: Keypair, + user: Keypair, + poolCreator: Keypair, + payer: Keypair, + feeVault: PublicKey, + quoteMint: PublicKey +) { + let instructionParams = buildDefaultCurve(); + const params: CreateConfigParams = { + payer, + leftoverReceiver: feeVault, + feeClaimer: feeVault, + quoteMint, + instructionParams, + }; + mintToken( + svm, + admin, + quoteMint, + admin, + user.publicKey, + instructionParams.migrationQuoteThreshold.mul(new BN(2)).toNumber() + ); + + const virtualPoolConfig = await createConfig(svm, params); + + const virtualPool = await createVirtualPool(svm, { + payer: poolCreator, + poolCreator: poolCreator, + quoteMint, + config: virtualPoolConfig, + instructionParams: { + name: "test token spl", + symbol: "TEST", + uri: "abc.com", + }, + }); + + // transfer pool creator + await transferCreator(svm, virtualPool, poolCreator, feeVault); + + let virtualPoolState = getVirtualPoolState(svm, virtualPool); + let configState = getVirtualConfigState(svm, virtualPoolConfig); + const amountIn = configState.migrationQuoteThreshold + .mul(new BN(6)) + .div(new BN(5)); + // swap + const swapParams: SwapParams = { + config: virtualPoolConfig, + payer: user, + pool: virtualPool, + inputTokenMint: quoteMint, + outputTokenMint: virtualPoolState.baseMint, + amountIn, + minimumAmountOut: new BN(0), + referralTokenAccount: null, + }; + await swap(svm, swapParams); + + return { virtualPool, virtualPoolConfig }; +} diff --git a/tests/common/damm_v2.ts b/tests/common/damm_v2.ts new file mode 100644 index 0000000..3042a13 --- /dev/null +++ b/tests/common/damm_v2.ts @@ -0,0 +1,322 @@ +import { + AnchorProvider, + BN, + IdlAccounts, + Program, + Wallet, +} from "@coral-xyz/anchor"; + +import { CpAmm } from "./idl/damm_v2"; +import CpAmmIDL from "../../idls/damm_v2.json"; +import { clusterApiUrl, Connection, Keypair, PublicKey, Transaction } from "@solana/web3.js"; +import { LiteSVM } from "litesvm"; +import { + getAssociatedTokenAddressSync, + TOKEN_2022_PROGRAM_ID, + TOKEN_PROGRAM_ID, +} from "@solana/spl-token"; +import { sendTransactionOrExpectThrowError } from "./svm"; + +export const DAMM_V2_PROGRAM_ID = new PublicKey(CpAmmIDL.address); + +export type Pool = IdlAccounts["pool"]; +export type Position = IdlAccounts["position"]; + +// export const ClaimFeeIx = CpAmmIDL.instructions[1].discriminator; + +export const MIN_SQRT_PRICE = new BN("4295048016"); +export const MAX_SQRT_PRICE = new BN("79226673521066979257578248091"); +const LIQUIDITY_DELTA = new BN("1844674407800459963300003758876517305"); +const INIT_PRICE = new BN("18446744073709551616"); + +export function createDammV2Program() { + const wallet = new Wallet(Keypair.generate()); + const provider = new AnchorProvider( + new Connection(clusterApiUrl("devnet")), + wallet, + {} + ); + const program = new Program(CpAmmIDL as CpAmm, provider); + return program; +} + +export async function createDammV2Pool( + svm: LiteSVM, + creator: Keypair, + tokenAMint: PublicKey, + tokenBMint: PublicKey +): Promise<{ + pool: PublicKey; + position: PublicKey; + positionNftAccount: PublicKey; +}> { + const program = createDammV2Program(); + + const poolAuthority = deriveDammV2PoolAuthority(); + const pool = deriveDammV2CustomizablePoolAddress(tokenAMint, tokenBMint); + + const positionNftKP = Keypair.generate(); + const position = deriveDammV2PositionAddress(positionNftKP.publicKey); + const positionNftAccount = deriveDammV2PositionNftAccount( + positionNftKP.publicKey + ); + + const tokenAVault = deriveDammV2TokenVaultAddress(tokenAMint, pool); + const tokenBVault = deriveDammV2TokenVaultAddress(tokenBMint, pool); + + const payerTokenA = getAssociatedTokenAddressSync( + tokenAMint, + creator.publicKey, + true, + TOKEN_PROGRAM_ID + ); + const payerTokenB = getAssociatedTokenAddressSync( + tokenBMint, + creator.publicKey, + true, + TOKEN_PROGRAM_ID + ); + + const transaction = await program.methods + .initializeCustomizablePool({ + poolFees: { + baseFee: { + cliffFeeNumerator: new BN(10_000_000), + numberOfPeriod: 0, + reductionFactor: new BN(0), + periodFrequency: new BN(0), + feeSchedulerMode: 0, + }, + padding: new Array(3).fill(0), + dynamicFee: null, + }, + sqrtMinPrice: MIN_SQRT_PRICE, + sqrtMaxPrice: MAX_SQRT_PRICE, + hasAlphaVault: false, + liquidity: LIQUIDITY_DELTA, + sqrtPrice: INIT_PRICE, + activationType: 0, + collectFeeMode: 1, // collect fee mode: onlyB + activationPoint: null, + }) + .accountsPartial({ + creator: creator.publicKey, + positionNftAccount, + positionNftMint: positionNftKP.publicKey, + payer: creator.publicKey, + poolAuthority, + pool, + position, + tokenAMint, + tokenBMint, + tokenAVault, + tokenBVault, + payerTokenA, + payerTokenB, + token2022Program: TOKEN_2022_PROGRAM_ID, + tokenAProgram: TOKEN_PROGRAM_ID, + tokenBProgram: TOKEN_PROGRAM_ID, + }) + .transaction(); + transaction.recentBlockhash = svm.latestBlockhash(); + transaction.sign(creator, positionNftKP); + + sendTransactionOrExpectThrowError(svm, transaction); + + return { pool, position, positionNftAccount }; +} + +export async function initializeAndFundReward(svm: LiteSVM, creator: Keypair, pool: PublicKey, rewardMint: PublicKey, rewardIndex: number) { + const program = createDammV2Program(); + + const initTx = await program.methods.initializeReward( + rewardIndex, + new BN(60 * 60 * 24), + creator.publicKey + ).accountsPartial({ + poolAuthority: deriveDammV2PoolAuthority(), + pool, + rewardVault: deriveDammV2RewardVault(pool, rewardIndex), + rewardMint, + signer: creator.publicKey, + payer: creator.publicKey, + tokenProgram: TOKEN_PROGRAM_ID + }).transaction() + + const amount = new BN(100_000_000) + const fundReward = await program.methods.fundReward(rewardIndex, amount, false).accountsPartial({ + pool, + rewardMint, + rewardVault: deriveDammV2RewardVault(pool, rewardIndex), + funderTokenAccount: getAssociatedTokenAddressSync(rewardMint, creator.publicKey, true, TOKEN_PROGRAM_ID), + funder: creator.publicKey, + tokenProgram: TOKEN_PROGRAM_ID + }).transaction() + + const transaction = new Transaction().add(initTx).add(fundReward) + transaction.recentBlockhash = svm.latestBlockhash(); + transaction.sign(creator); + + sendTransactionOrExpectThrowError(svm, transaction); +} + +export function getProgramFromFlagDammV2(flag: number): PublicKey { + return flag == 0 ? TOKEN_PROGRAM_ID : TOKEN_2022_PROGRAM_ID; +} + +export function getDammV2PoolState(svm: LiteSVM, dammV2Pool: PublicKey): Pool { + const program = createDammV2Program(); + const account = svm.getAccount(dammV2Pool); + return program.coder.accounts.decode("pool", Buffer.from(account.data)); +} + +export function deriveDammV2PositionAddress(positionNft: PublicKey): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("position"), positionNft.toBuffer()], + DAMM_V2_PROGRAM_ID + )[0]; +} + +export function deriveDammV2PositionNftAccount( + positionNftMint: PublicKey +): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("position_nft_account"), positionNftMint.toBuffer()], + DAMM_V2_PROGRAM_ID + )[0]; +} + +export function deriveDammV2CustomizablePoolAddress( + tokenAMint: PublicKey, + tokenBMint: PublicKey +): PublicKey { + return PublicKey.findProgramAddressSync( + [ + Buffer.from("cpool"), + getFirstKey(tokenAMint, tokenBMint), + getSecondKey(tokenAMint, tokenBMint), + ], + DAMM_V2_PROGRAM_ID + )[0]; +} + +export function deriveDammV2TokenVaultAddress( + tokenMint: PublicKey, + pool: PublicKey +): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("token_vault"), tokenMint.toBuffer(), pool.toBuffer()], + DAMM_V2_PROGRAM_ID + )[0]; +} + +export function deriveDammV2EventAuthority() { + return PublicKey.findProgramAddressSync( + [Buffer.from("__event_authority")], + DAMM_V2_PROGRAM_ID + )[0]; +} + +export function deriveDammV2RewardVault(pool: PublicKey, rewardIndex: number): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("reward_vault"), pool.toBuffer(), Buffer.from([rewardIndex])], + DAMM_V2_PROGRAM_ID + )[0]; +} + +export function deriveDammV2PoolAuthority(): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("pool_authority")], + DAMM_V2_PROGRAM_ID + )[0]; +} + +export function getSecondKey(key1: PublicKey, key2: PublicKey) { + const buf1 = key1.toBuffer(); + const buf2 = key2.toBuffer(); + // Buf1 > buf2 + if (Buffer.compare(buf1, buf2) === 1) { + return buf2; + } + return buf1; +} + +export function getFirstKey(key1: PublicKey, key2: PublicKey) { + const buf1 = key1.toBuffer(); + const buf2 = key2.toBuffer(); + // Buf1 > buf2 + if (Buffer.compare(buf1, buf2) === 1) { + return buf1; + } + return buf2; +} + +export type SwapParams = { + payer: Keypair; + pool: PublicKey; + inputTokenMint: PublicKey; + outputTokenMint: PublicKey; + amountIn: BN; + minimumAmountOut: BN; +}; + +export async function dammV2Swap(svm: LiteSVM, params: SwapParams) { + const { + payer, + pool, + inputTokenMint, + outputTokenMint, + amountIn, + minimumAmountOut, + } = params; + + const program = createDammV2Program(); + + const poolState = getDammV2PoolState(svm, pool); + + const tokenAProgram = svm.getAccount(poolState.tokenAMint).owner; + + const tokenBProgram = svm.getAccount(poolState.tokenBMint).owner; + const inputTokenAccount = getAssociatedTokenAddressSync( + inputTokenMint, + payer.publicKey, + true, + tokenAProgram + ); + const outputTokenAccount = getAssociatedTokenAddressSync( + outputTokenMint, + payer.publicKey, + true, + tokenBProgram + ); + const tokenAVault = poolState.tokenAVault; + const tokenBVault = poolState.tokenBVault; + const tokenAMint = poolState.tokenAMint; + const tokenBMint = poolState.tokenBMint; + + const transaction = await program.methods + .swap({ + amountIn, + minimumAmountOut, + }) + .accountsPartial({ + poolAuthority: deriveDammV2PoolAuthority(), + pool, + payer: payer.publicKey, + inputTokenAccount, + outputTokenAccount, + tokenAVault, + tokenBVault, + tokenAProgram, + tokenBProgram, + tokenAMint, + tokenBMint, + referralTokenAccount: null, + }) + .transaction(); + + transaction.recentBlockhash = svm.latestBlockhash(); + transaction.sign(payer); + + sendTransactionOrExpectThrowError(svm, transaction); +} diff --git a/tests/common/dbc.ts b/tests/common/dbc.ts new file mode 100644 index 0000000..76deb0b --- /dev/null +++ b/tests/common/dbc.ts @@ -0,0 +1,867 @@ +import { + AnchorProvider, + BN, + IdlAccounts, + Program, + Wallet, +} from "@coral-xyz/anchor"; + +import { DynamicBondingCurve } from "./idl/dynamic_bonding_curve"; +import DynamicBondingCurveIDL from "../../idls/dynamic_bonding_curve.json"; +import { + clusterApiUrl, + ComputeBudgetProgram, + Connection, + Keypair, + PublicKey, + SYSVAR_INSTRUCTIONS_PUBKEY, + TransactionInstruction, +} from "@solana/web3.js"; +import { LiteSVM } from "litesvm"; +import { + getAssociatedTokenAddressSync, + NATIVE_MINT, + TOKEN_2022_PROGRAM_ID, + TOKEN_PROGRAM_ID, +} from "@solana/spl-token"; +import { + getFirstKey, + getSecondKey, + MAX_SQRT_PRICE, + MIN_SQRT_PRICE, +} from "./damm_v2"; +import Decimal from "decimal.js"; +import { sendTransactionOrExpectThrowError } from "./svm"; +import { getOrCreateAtA, unwrapSOLInstruction, wrapSOLInstruction } from "."; + +export const DBC_PROGRAM_ID = new PublicKey(DynamicBondingCurveIDL.address); +export type VirtualPool = IdlAccounts["virtualPool"]; +export type PoolConfig = IdlAccounts["poolConfig"]; + +export function createDBCProgram() { + const wallet = new Wallet(Keypair.generate()); + const provider = new AnchorProvider( + new Connection(clusterApiUrl("devnet")), + wallet, + {} + ); + const program = new Program( + DynamicBondingCurveIDL as DynamicBondingCurve, + provider + ); + return program; +} + +export async function createConfig( + svm: LiteSVM, + params: CreateConfigParams +): Promise { + const { payer, leftoverReceiver, feeClaimer, quoteMint, instructionParams } = + params; + const config = Keypair.generate(); + + const program = createDBCProgram(); + + const transaction = await program.methods + .createConfig(instructionParams) + .accountsPartial({ + config: config.publicKey, + feeClaimer, + leftoverReceiver, + quoteMint, + payer: payer.publicKey, + }) + .transaction(); + + transaction.recentBlockhash = svm.latestBlockhash(); + transaction.sign(payer, config); + + sendTransactionOrExpectThrowError(svm, transaction); + + return config.publicKey; +} + +export type CreatePoolToken2022Params = { + payer: Keypair; + poolCreator: Keypair; + quoteMint: PublicKey; + config: PublicKey; + instructionParams: { + name: string; + symbol: string; + uri: string; + }; +}; + +export async function createVirtualPool( + svm: LiteSVM, + params: CreatePoolToken2022Params +): Promise { + const { payer, quoteMint, config, instructionParams, poolCreator } = params; + const program = createDBCProgram(); + const poolAuthority = deriveDbcPoolAuthority(); + const baseMintKP = Keypair.generate(); + const pool = derivePoolAddress(config, baseMintKP.publicKey, quoteMint); + const baseVault = deriveTokenVaultAddress(baseMintKP.publicKey, pool); + const quoteVault = deriveTokenVaultAddress(quoteMint, pool); + const transaction = await program.methods + .initializeVirtualPoolWithToken2022(instructionParams) + .accountsPartial({ + config, + baseMint: baseMintKP.publicKey, + quoteMint, + pool, + payer: payer.publicKey, + creator: poolCreator.publicKey, + poolAuthority, + baseVault, + quoteVault, + tokenQuoteProgram: TOKEN_PROGRAM_ID, + tokenProgram: TOKEN_2022_PROGRAM_ID, + }) + .transaction(); + + transaction.add( + ComputeBudgetProgram.setComputeUnitLimit({ + units: 400_000, + }) + ); + + transaction.recentBlockhash = svm.latestBlockhash(); + transaction.sign(payer, baseMintKP, poolCreator); + + sendTransactionOrExpectThrowError(svm, transaction); + + return pool; +} + +export type SwapParams = { + config: PublicKey; + payer: Keypair; + pool: PublicKey; + inputTokenMint: PublicKey; + outputTokenMint: PublicKey; + amountIn: BN; + minimumAmountOut: BN; + referralTokenAccount: PublicKey | null; +}; + +export async function swap(svm: LiteSVM, params: SwapParams): Promise { + const { + config, + payer, + pool, + inputTokenMint, + outputTokenMint, + amountIn, + minimumAmountOut, + referralTokenAccount, + } = params; + + const poolAuthority = deriveDbcPoolAuthority(); + let poolState = getVirtualPoolState(svm, pool); + const program = createDBCProgram(); + + const tokenBaseProgram = TOKEN_2022_PROGRAM_ID; + + const isInputBaseMint = inputTokenMint.equals(poolState.baseMint); + + const quoteMint = isInputBaseMint ? outputTokenMint : inputTokenMint; + const [inputTokenProgram, outputTokenProgram] = isInputBaseMint + ? [tokenBaseProgram, TOKEN_PROGRAM_ID] + : [TOKEN_PROGRAM_ID, tokenBaseProgram]; + + const preInstructions: TransactionInstruction[] = []; + const postInstructions: TransactionInstruction[] = []; + + const [inputTokenAccount, outputTokenAccount] = [ + getOrCreateAtA( + svm, + payer, + inputTokenMint, + payer.publicKey, + inputTokenProgram + ), + getOrCreateAtA( + svm, + payer, + outputTokenMint, + payer.publicKey, + outputTokenProgram + ), + ]; + + if (inputTokenMint.equals(NATIVE_MINT) && !amountIn.isZero()) { + const wrapSOLIx = wrapSOLInstruction( + payer.publicKey, + inputTokenAccount, + BigInt(amountIn.toString()) + ); + + preInstructions.push(...wrapSOLIx); + } + + if (outputTokenMint.equals(NATIVE_MINT)) { + const unrapSOLIx = unwrapSOLInstruction(payer.publicKey); + + unrapSOLIx && postInstructions.push(unrapSOLIx); + } + + const transaction = await program.methods + .swap({ amountIn, minimumAmountOut }) + .accountsPartial({ + poolAuthority, + config, + pool, + inputTokenAccount, + outputTokenAccount, + baseVault: poolState.baseVault, + quoteVault: poolState.quoteVault, + baseMint: poolState.baseMint, + quoteMint, + payer: payer.publicKey, + tokenBaseProgram, + tokenQuoteProgram: TOKEN_PROGRAM_ID, + referralTokenAccount, + }) + .remainingAccounts( + // TODO should check condition to add this in remaning accounts + [ + { + isSigner: false, + isWritable: false, + pubkey: SYSVAR_INSTRUCTIONS_PUBKEY, + }, + ] + ) + .preInstructions(preInstructions) + .postInstructions(postInstructions) + .transaction(); + + transaction.add( + ComputeBudgetProgram.setComputeUnitLimit({ + units: 400_000, + }) + ); + + transaction.recentBlockhash = svm.latestBlockhash(); + transaction.sign(payer); + + sendTransactionOrExpectThrowError(svm, transaction); +} + +export async function transferCreator( + svm: LiteSVM, + virtualPool: PublicKey, + creator: Keypair, + newCreator: PublicKey +): Promise { + const program = createDBCProgram(); + const poolState = getVirtualPoolState(svm, virtualPool); + const migrationMetadata = deriveMigrationMetadataAddress(virtualPool); + const transaction = await program.methods + .transferPoolCreator() + .accountsPartial({ + virtualPool, + newCreator, + config: poolState.config, + creator: creator.publicKey, + }) + .remainingAccounts([ + { + isSigner: false, + isWritable: false, + pubkey: migrationMetadata, + }, + ]) + .transaction(); + + transaction.recentBlockhash = svm.latestBlockhash(); + transaction.sign(creator); + + sendTransactionOrExpectThrowError(svm, transaction); +} + +export function getVirtualPoolState( + svm: LiteSVM, + virtualPool: PublicKey +): VirtualPool { + const program = createDBCProgram(); + const account = svm.getAccount(virtualPool); + return program.coder.accounts.decode( + "virtualPool", + Buffer.from(account.data) + ); +} + +export function getVirtualConfigState( + svm: LiteSVM, + virtualPool: PublicKey +): PoolConfig { + const program = createDBCProgram(); + const account = svm.getAccount(virtualPool); + return program.coder.accounts.decode("poolConfig", Buffer.from(account.data)); +} + +export function deriveMigrationMetadataAddress( + virtual_pool: PublicKey +): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("meteora"), virtual_pool.toBuffer()], + DBC_PROGRAM_ID + )[0]; +} + +function derivePoolAddress( + config: PublicKey, + tokenAMint: PublicKey, + tokenBMint: PublicKey +): PublicKey { + return PublicKey.findProgramAddressSync( + [ + Buffer.from("pool"), + config.toBuffer(), + getFirstKey(tokenAMint, tokenBMint), + getSecondKey(tokenAMint, tokenBMint), + ], + DBC_PROGRAM_ID + )[0]; +} + +export function deriveDbcPoolAuthority(): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("pool_authority")], + DBC_PROGRAM_ID + )[0]; +} + +export function deriveDbcEventAuthority() { + return PublicKey.findProgramAddressSync( + [Buffer.from("__event_authority")], + DBC_PROGRAM_ID + )[0]; +} + +function deriveTokenVaultAddress( + tokenMint: PublicKey, + pool: PublicKey +): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("token_vault"), tokenMint.toBuffer(), pool.toBuffer()], + DBC_PROGRAM_ID + )[0]; +} + +////// DBC utils + +export function buildDefaultCurve(): ConfigParameters { + let totalTokenSupply = 1_000_000_000; + let percentageSupplyOnMigration = 10; // 10%; + let migrationQuoteThreshold = 300; // 300 sol + let migrationOption = 1; // damm v2 + let tokenBaseDecimal = 6; + let tokenQuoteDecimal = 9; + let creatorTradingFeePercentage = 50; + let collectFeeMode = 0; + + let migrationBaseSupply = new BN(totalTokenSupply) + .mul(new BN(percentageSupplyOnMigration)) + .div(new BN(100)); + + let totalSupply = new BN(totalTokenSupply).mul( + new BN(10).pow(new BN(tokenBaseDecimal)) + ); + let migrationQuoteThresholdWithDecimals = new BN( + migrationQuoteThreshold * 10 ** tokenQuoteDecimal + ); + + let migrationPrice = new Decimal(migrationQuoteThreshold.toString()).div( + new Decimal(migrationBaseSupply.toString()) + ); + let migrateSqrtPrice = getSqrtPriceFromPrice( + migrationPrice.toString(), + tokenBaseDecimal, + tokenQuoteDecimal + ); + + let migrationBaseAmount = getMigrationBaseToken( + new BN(migrationQuoteThresholdWithDecimals), + migrateSqrtPrice, + migrationOption + ); + let swapAmount = totalSupply.sub(migrationBaseAmount); + + let { sqrtStartPrice, curve } = getFirstCurve( + migrateSqrtPrice, + migrationBaseAmount, + swapAmount, + migrationQuoteThresholdWithDecimals + ); + + let totalDynamicSupply = getTotalSupplyFromCurve( + migrationQuoteThresholdWithDecimals, + sqrtStartPrice, + curve, + migrationOption, + new BN(0) + ); + + let remainingAmount = totalSupply.sub(totalDynamicSupply); + + let lastLiquidity = getInitialLiquidityFromDeltaBase( + remainingAmount, + MAX_SQRT_PRICE, + migrateSqrtPrice + ); + if (!lastLiquidity.isZero()) { + curve.push({ + sqrtPrice: MAX_SQRT_PRICE, + liquidity: lastLiquidity, + }); + } + + const instructionParams: ConfigParameters = { + poolFees: { + baseFee: { + cliffFeeNumerator: new BN(2_500_000), + firstFactor: 0, + secondFactor: new BN(0), + thirdFactor: new BN(0), + baseFeeMode: 0, + }, + dynamicFee: null, + }, + activationType: 0, + collectFeeMode, + migrationOption, + tokenType: 1, // token 2022 + tokenDecimal: tokenBaseDecimal, + migrationQuoteThreshold: migrationQuoteThresholdWithDecimals, + partnerLpPercentage: 0, + creatorLpPercentage: 0, + partnerLockedLpPercentage: 100, + creatorLockedLpPercentage: 0, + sqrtStartPrice, + lockedVesting: { + amountPerPeriod: new BN(0), + cliffDurationFromMigrationTime: new BN(0), + frequency: new BN(0), + numberOfPeriod: new BN(0), + cliffUnlockAmount: new BN(0), + }, + migrationFeeOption: 0, + tokenSupply: { + preMigrationTokenSupply: totalSupply, + postMigrationTokenSupply: totalSupply, + }, + creatorTradingFeePercentage, + tokenUpdateAuthority: 0, + migrationFee: { + feePercentage: 50, + creatorFeePercentage: 50, + }, + migratedPoolFee: { + collectFeeMode: 0, + dynamicFee: 0, + poolFeeBps: 0, + }, + padding: [], + curve, + }; + return instructionParams; +} + +type BaseFee = { + cliffFeeNumerator: BN; + firstFactor: number; + secondFactor: BN; + thirdFactor: BN; + baseFeeMode: number; +}; + +type DynamicFee = { + binStep: number; + binStepU128: BN; + filterPeriod: number; + decayPeriod: number; + reductionFactor: number; + maxVolatilityAccumulator: number; + variableFeeControl: number; +}; + +type LockedVestingParams = { + amountPerPeriod: BN; + cliffDurationFromMigrationTime: BN; + frequency: BN; + numberOfPeriod: BN; + cliffUnlockAmount: BN; +}; + +type TokenSupplyParams = { + preMigrationTokenSupply: BN; + postMigrationTokenSupply: BN; +}; + +type ConfigParameters = { + poolFees: { + baseFee: BaseFee; + dynamicFee: DynamicFee | null; + }; + collectFeeMode: number; + migrationOption: number; + activationType: number; + tokenType: number; + tokenDecimal: number; + migrationQuoteThreshold: BN; + partnerLpPercentage: number; + partnerLockedLpPercentage: number; + creatorLpPercentage: number; + creatorLockedLpPercentage: number; + sqrtStartPrice: BN; + lockedVesting: LockedVestingParams; + migrationFeeOption: number; + tokenSupply: TokenSupplyParams | null; + creatorTradingFeePercentage: number; + tokenUpdateAuthority: number; + migrationFee: { + feePercentage: number; + creatorFeePercentage: number; + }; + migratedPoolFee: { + poolFeeBps: number; + collectFeeMode: number; + dynamicFee: number; + }; + padding: BN[]; + curve: Array; +}; + +type LiquidityDistributionParameters = { + sqrtPrice: BN; + liquidity: BN; +}; + +export type CreateConfigParams = { + payer: Keypair; + leftoverReceiver: PublicKey; + feeClaimer: PublicKey; + quoteMint: PublicKey; + instructionParams: ConfigParameters; +}; + +const getSqrtPriceFromPrice = ( + price: string, + tokenADecimal: number, + tokenBDecimal: number +): BN => { + const decimalPrice = new Decimal(price); + const adjustedByDecimals = decimalPrice.div( + new Decimal(10 ** (tokenADecimal - tokenBDecimal)) + ); + const sqrtValue = Decimal.sqrt(adjustedByDecimals); + const sqrtValueQ64 = sqrtValue.mul(Decimal.pow(2, 64)); + + return new BN(sqrtValueQ64.floor().toFixed()); +}; + +const getInitialLiquidityFromDeltaQuote = ( + quoteAmount: BN, + sqrtMinPrice: BN, + sqrtPrice: BN +): BN => { + let priceDelta = sqrtPrice.sub(sqrtMinPrice); + quoteAmount = quoteAmount.shln(128); + let liquidity = quoteAmount.div(priceDelta); // round down + return liquidity; +}; + +function getDeltaAmountBase( + lowerSqrtPrice: BN, + upperSqrtPrice: BN, + liquidity: BN +): BN { + let numerator = liquidity.mul(upperSqrtPrice.sub(lowerSqrtPrice)); + let denominator = lowerSqrtPrice.mul(upperSqrtPrice); + return numerator.add(denominator).sub(new BN(1)).div(denominator); +} + +const getMigrationBaseToken = ( + migrationQuoteThreshold: BN, + sqrtMigrationPrice: BN, + migrationOption: number +): BN => { + if (migrationOption == 0) { + let price = sqrtMigrationPrice.mul(sqrtMigrationPrice); + let quote = migrationQuoteThreshold.shln(128); + let { div, mod } = quote.divmod(price); + if (!mod.isZero()) { + div = div.add(new BN(1)); + } + return div; + } else if (migrationOption == 1) { + let liquidity = getInitialLiquidityFromDeltaQuote( + migrationQuoteThreshold, + MIN_SQRT_PRICE, + sqrtMigrationPrice + ); + // calculate base threshold + let baseAmount = getDeltaAmountBase( + sqrtMigrationPrice, + MAX_SQRT_PRICE, + liquidity + ); + return baseAmount; + } else { + throw Error("Invalid migration option"); + } +}; + +const getNextSqrtPriceFromInput = ( + sqrtPrice: BN, + liquidity: BN, + amountIn: BN, + baseForQuote: boolean +): BN => { + // round to make sure that we don't pass the target price + if (baseForQuote) { + return getNextSqrtPriceFromAmountBaseRoundingUp( + sqrtPrice, + liquidity, + amountIn + ); + } else { + return getNextSqrtPriceFromAmountQuoteRoundingDown( + sqrtPrice, + liquidity, + amountIn + ); + } +}; + +// √P' = √P * L / (L + Δx * √P) +const getNextSqrtPriceFromAmountBaseRoundingUp = ( + sqrtPrice: BN, + liquidity: BN, + amount: BN +): BN => { + if (amount.isZero()) { + return sqrtPrice; + } + let prod = sqrtPrice.mul(liquidity); + let denominator = liquidity.add(amount.mul(sqrtPrice)); + let result = prod.add(denominator).sub(new BN(1)).div(denominator); + return result; +}; + +/// * `√P' = √P + Δy / L` +/// +const getNextSqrtPriceFromAmountQuoteRoundingDown = ( + sqrtPrice: BN, + liquidity: BN, + amount: BN +): BN => { + return sqrtPrice.add(amount.shln(128).div(liquidity)); +}; + +// Δa = L * (1 / √P_lower - 1 / √P_upper) => L = Δa / (1 / √P_lower - 1 / √P_upper) +const getInitialLiquidityFromDeltaBase = ( + baseAmount: BN, + sqrtMaxPrice: BN, + sqrtPrice: BN +): BN => { + let priceDelta = sqrtMaxPrice.sub(sqrtPrice); + let prod = baseAmount.mul(sqrtMaxPrice).mul(sqrtPrice); + let liquidity = prod.div(priceDelta); // round down + return liquidity; +}; + +const getDeltaAmountQuote = ( + lowerSqrtPrice: BN, + upperSqrtPrice: BN, + liquidity: BN, + round: String +): BN => { + let detalPrice = upperSqrtPrice.sub(lowerSqrtPrice); + let prod = liquidity.mul(detalPrice); + let denominator = new BN(1).shln(128); + if (round == "U") { + let result = prod.add(denominator).sub(new BN(1)).div(denominator); + return result; + } else if (round == "D") { + let result = prod.div(denominator); + return result; + } else { + throw Error("Invalid rounding"); + } +}; + +const getMigrationThresholdPrice = ( + migrationThreshold: BN, + sqrtStartPrice: BN, + curve: Array +): BN => { + let nextSqrtPrice = sqrtStartPrice; + let totalAmount = getDeltaAmountQuote( + nextSqrtPrice, + curve[0].sqrtPrice, + curve[0].liquidity, + "U" + ); + if (totalAmount.gt(migrationThreshold)) { + nextSqrtPrice = getNextSqrtPriceFromInput( + nextSqrtPrice, + curve[0].liquidity, + migrationThreshold, + false + ); + } else { + let amountLeft = migrationThreshold.sub(totalAmount); + nextSqrtPrice = curve[0].sqrtPrice; + for (let i = 1; i < curve.length; i++) { + let maxAmount = getDeltaAmountQuote( + nextSqrtPrice, + curve[i].sqrtPrice, + curve[i].liquidity, + "U" + ); + if (maxAmount.gt(amountLeft)) { + nextSqrtPrice = getNextSqrtPriceFromInput( + nextSqrtPrice, + curve[i].liquidity, + amountLeft, + false + ); + amountLeft = new BN(0); + break; + } else { + amountLeft = amountLeft.sub(maxAmount); + nextSqrtPrice = curve[i].sqrtPrice; + } + } + if (!amountLeft.isZero()) { + console.log("migrationThreshold: ", migrationThreshold.toString()); + throw Error("Not enough liquidity, amountLeft: " + amountLeft.toString()); + } + } + return nextSqrtPrice; +}; + +function getBaseTokenForSwap( + sqrtStartPrice: BN, + sqrtMigrationPrice: BN, + curve: Array +): BN { + let totalAmount = new BN(0); + for (let i = 0; i < curve.length; i++) { + let lowerSqrtPrice = i == 0 ? sqrtStartPrice : curve[i - 1].sqrtPrice; + if (curve[i].sqrtPrice > sqrtMigrationPrice) { + let deltaAmount = getDeltaAmountBase( + lowerSqrtPrice, + sqrtMigrationPrice, + curve[i].liquidity + ); + totalAmount = totalAmount.add(deltaAmount); + break; + } else { + let deltaAmount = getDeltaAmountBase( + lowerSqrtPrice, + curve[i].sqrtPrice, + curve[i].liquidity + ); + totalAmount = totalAmount.add(deltaAmount); + } + } + return totalAmount; +} + +const getSwapAmountWithBuffer = ( + swapBaseAmount: BN, + sqrtStartPrice: BN, + curve: Array +): BN => { + let swapAmountBuffer = swapBaseAmount.add( + swapBaseAmount.mul(new BN(25)).div(new BN(100)) + ); + let maxBaseAmountOnCurve = getBaseTokenForSwap( + sqrtStartPrice, + MAX_SQRT_PRICE, + curve + ); + return BN.min(swapAmountBuffer, maxBaseAmountOnCurve); +}; + +const getTotalSupplyFromCurve = ( + migrationQuoteThreshold: BN, + sqrtStartPrice: BN, + curve: Array, + migrationOption: number, + leftOver: BN +): BN => { + let sqrtMigrationPrice = getMigrationThresholdPrice( + migrationQuoteThreshold, + sqrtStartPrice, + curve + ); + let swapBaseAmount = getBaseTokenForSwap( + sqrtStartPrice, + sqrtMigrationPrice, + curve + ); + let swapBaseAmountBuffer = getSwapAmountWithBuffer( + swapBaseAmount, + sqrtStartPrice, + curve + ); + let migrationBaseAmount = getMigrationBaseToken( + migrationQuoteThreshold, + sqrtMigrationPrice, + migrationOption + ); + let minimumBaseSupplyWithBuffer = swapBaseAmountBuffer + .add(migrationBaseAmount) + .add(leftOver); + return minimumBaseSupplyWithBuffer; +}; + +const getLiquidity = ( + baseAmount: BN, + quoteAmount: BN, + minSqrtPrice: BN, + maxSqrtPrice: BN +): BN => { + let liquidityFromBase = getInitialLiquidityFromDeltaBase( + baseAmount, + maxSqrtPrice, + minSqrtPrice + ); + let liquidityFromQuote = getInitialLiquidityFromDeltaQuote( + quoteAmount, + minSqrtPrice, + maxSqrtPrice + ); + return BN.min(liquidityFromBase, liquidityFromQuote); +}; + +const getFirstCurve = ( + migrationSqrPrice: BN, + migrationAmount: BN, + swapAmount: BN, + migrationQuoteThreshold: BN +) => { + let sqrtStartPrice = migrationSqrPrice.mul(migrationAmount).div(swapAmount); + let liquidity = getLiquidity( + swapAmount, + migrationQuoteThreshold, + sqrtStartPrice, + migrationSqrPrice + ); + return { + sqrtStartPrice, + curve: [ + { + sqrtPrice: migrationSqrPrice, + liquidity, + }, + ], + }; +}; diff --git a/tests/common/dfs.ts b/tests/common/dfs.ts new file mode 100644 index 0000000..8fcc364 --- /dev/null +++ b/tests/common/dfs.ts @@ -0,0 +1,673 @@ +import { AccountMeta, Keypair, PublicKey } from "@solana/web3.js"; +import CpAmmIDL from "../../idls/damm_v2.json"; +import DynamicBondingCurveIDL from "../../idls/dynamic_bonding_curve.json"; +import { + createProgram, + deriveFeeVaultAuthorityAddress, + deriveFeeVaultPdaAddress, + deriveTokenVaultAddress, + getOrCreateAtA, + InitializeFeeVaultParameters, + U64_MAX, +} from "."; +import { LiteSVM } from "litesvm"; +import { + getAssociatedTokenAddressSync, + TOKEN_2022_PROGRAM_ID, + TOKEN_PROGRAM_ID, +} from "@solana/spl-token"; +import { + DAMM_V2_PROGRAM_ID, + deriveDammV2EventAuthority, + deriveDammV2PoolAuthority, + getDammV2PoolState, + getProgramFromFlagDammV2, +} from "./damm_v2"; +import { sendTransactionOrExpectThrowError } from "./svm"; +import { + DBC_PROGRAM_ID, + deriveDbcEventAuthority, + deriveDbcPoolAuthority, + getVirtualConfigState, + getVirtualPoolState, +} from "./dbc"; + +export async function createFeeVaultPda( + svm: LiteSVM, + admin: Keypair, + vaultOwner: PublicKey, + tokenMint: PublicKey, + params: InitializeFeeVaultParameters +): Promise<{ + feeVault: PublicKey; + tokenVault: PublicKey; +}> { + const program = createProgram(); + const baseKp = Keypair.generate(); + const feeVault = deriveFeeVaultPdaAddress(baseKp.publicKey, tokenMint); + const tokenVault = deriveTokenVaultAddress(feeVault); + const feeVaultAuthority = deriveFeeVaultAuthorityAddress(); + const tx = await program.methods + .initializeFeeVaultPda(params) + .accountsPartial({ + feeVault, + base: baseKp.publicKey, + feeVaultAuthority, + tokenVault, + tokenMint, + owner: vaultOwner, + payer: admin.publicKey, + tokenProgram: TOKEN_PROGRAM_ID, + }) + .transaction(); + + tx.recentBlockhash = svm.latestBlockhash(); + tx.sign(admin, baseKp); + + sendTransactionOrExpectThrowError(svm, tx); + + return { feeVault, tokenVault }; +} + +async function fundByClaimingFee(svm: LiteSVM, signer: Keypair, feeVault: PublicKey, tokenVault: PublicKey, remainingAccounts: AccountMeta[], payload: Buffer, sourceProgram: PublicKey) { + const program = createProgram(); + + const tx = await program.methods + .fundByClaimingFee(payload) + .accountsPartial({ + feeVault, + tokenVault, + signer: signer.publicKey, + sourceProgram + }) + .remainingAccounts( + remainingAccounts + ) + .transaction(); + + tx.recentBlockhash = svm.latestBlockhash(); + tx.sign(signer); + + const result = sendTransactionOrExpectThrowError(svm, tx); + + return result +} + +export async function claimDammV2Fee( + svm: LiteSVM, + signer: Keypair, + owner: Keypair, + feeVault: PublicKey, + tokenVault: PublicKey, + dammv2Pool: PublicKey, + position: PublicKey, + positionNftAccount: PublicKey, +) { + + const dammV2PoolState = getDammV2PoolState(svm, dammv2Pool); + + const tokenAAccount = getAssociatedTokenAddressSync( + dammV2PoolState.tokenAMint, + owner.publicKey, + true, + getProgramFromFlagDammV2(dammV2PoolState.tokenAFlag) + ); + + const remainingAccounts = [ + { + isSigner: false, + isWritable: false, + pubkey: deriveDammV2PoolAuthority(), + }, + { + isSigner: false, + isWritable: true, + pubkey: dammv2Pool, + }, + { + isSigner: false, + isWritable: true, + pubkey: position, + }, + { + isSigner: false, + isWritable: true, + pubkey: tokenAAccount, + }, + { + isSigner: false, + isWritable: true, + pubkey: tokenVault, + }, + { + isSigner: false, + isWritable: true, + pubkey: dammV2PoolState.tokenAVault, + }, + { + isSigner: false, + isWritable: true, + pubkey: dammV2PoolState.tokenBVault, + }, + { + isSigner: false, + isWritable: true, + pubkey: dammV2PoolState.tokenAMint, + }, + + { + isSigner: false, + isWritable: true, + pubkey: dammV2PoolState.tokenBMint, + }, + { + isSigner: false, + isWritable: false, + pubkey: positionNftAccount, + }, + { + isSigner: false, + isWritable: false, + pubkey: feeVault, + }, + { + isSigner: false, + isWritable: false, + pubkey: getProgramFromFlagDammV2(dammV2PoolState.tokenAFlag), + }, + { + isSigner: false, + isWritable: false, + pubkey: getProgramFromFlagDammV2(dammV2PoolState.tokenBFlag), + }, + { + isSigner: false, + isWritable: false, + pubkey: deriveDammV2EventAuthority(), + }, + { + isSigner: false, + isWritable: false, + pubkey: DAMM_V2_PROGRAM_ID, + }, + ]; + + const claimPositionFeeDisc = CpAmmIDL.instructions.find(instruction => instruction.name === "claim_position_fee").discriminator; + const payload = Buffer.from(claimPositionFeeDisc) + + await fundByClaimingFee(svm, signer, feeVault, tokenVault, remainingAccounts, payload, DAMM_V2_PROGRAM_ID) + +} + +export async function claimDammV2Reward( + svm: LiteSVM, + signer: Keypair, + owner: Keypair, + feeVault: PublicKey, + tokenVault: PublicKey, + dammv2Pool: PublicKey, + position: PublicKey, + positionNftAccount: PublicKey, + rewardIndex: number, +) { + + const dammV2PoolState = getDammV2PoolState(svm, dammv2Pool); + + const remainingAccounts = [ + { + isSigner: false, + isWritable: false, + pubkey: deriveDammV2PoolAuthority(), + }, + { + isSigner: false, + isWritable: true, + pubkey: dammv2Pool, + }, + { + isSigner: false, + isWritable: true, + pubkey: position, + }, + { + isSigner: false, + isWritable: true, + pubkey: dammV2PoolState.rewardInfos[rewardIndex].vault, + }, + { + isSigner: false, + isWritable: true, + pubkey: dammV2PoolState.rewardInfos[rewardIndex].mint, + }, + { + isSigner: false, + isWritable: true, + pubkey: tokenVault, + }, + { + isSigner: false, + isWritable: true, + pubkey: positionNftAccount, + }, + { + isSigner: false, + isWritable: false, + pubkey: feeVault, + }, + { + isSigner: false, + isWritable: false, + pubkey: getProgramFromFlagDammV2(dammV2PoolState.rewardInfos[rewardIndex].rewardTokenFlag), + }, + { + isSigner: false, + isWritable: false, + pubkey: deriveDammV2EventAuthority(), + }, + { + isSigner: false, + isWritable: false, + pubkey: DAMM_V2_PROGRAM_ID, + }, + ]; + + const claimDammV2RewardDisc = CpAmmIDL.instructions.find(instruction => instruction.name === "claim_reward").discriminator; + const payload = Buffer.concat([Buffer.from(claimDammV2RewardDisc), Buffer.from([rewardIndex]), Buffer.from([1])]) + await fundByClaimingFee(svm, signer, feeVault, tokenVault, remainingAccounts, payload, DAMM_V2_PROGRAM_ID) + +} + +export async function claimDbcCreatorTradingFee( + svm: LiteSVM, + signer: Keypair, + feeVault: PublicKey, + tokenVault: PublicKey, + poolConfig: PublicKey, + virtualPool: PublicKey +) { + const virtualPoolState = getVirtualPoolState(svm, virtualPool); + const poolConfigState = getVirtualConfigState(svm, poolConfig); + + const tokenAAccount = getOrCreateAtA( + svm, + signer, + virtualPoolState.baseMint, + signer.publicKey, + TOKEN_2022_PROGRAM_ID + ); + + const remainingAccounts = [ + { + isSigner: false, + isWritable: false, + pubkey: deriveDbcPoolAuthority(), + }, + { + isSigner: false, + isWritable: true, + pubkey: virtualPool, + }, + { + isSigner: false, + isWritable: true, + pubkey: tokenAAccount, + }, + { + isSigner: false, + isWritable: true, + pubkey: tokenVault, + }, + { + isSigner: false, + isWritable: true, + pubkey: virtualPoolState.baseVault, + }, + { + isSigner: false, + isWritable: true, + pubkey: virtualPoolState.quoteVault, + }, + { + isSigner: false, + isWritable: false, + pubkey: virtualPoolState.baseMint, + }, + { + isSigner: false, + isWritable: false, + pubkey: poolConfigState.quoteMint, + }, + { + isSigner: false, + isWritable: false, + pubkey: feeVault, + }, + { + isSigner: false, + isWritable: false, + pubkey: TOKEN_2022_PROGRAM_ID, + }, + { + isSigner: false, + isWritable: false, + pubkey: TOKEN_PROGRAM_ID, + }, + { + isSigner: false, + isWritable: false, + pubkey: deriveDbcEventAuthority(), + }, + { + isSigner: false, + isWritable: false, + pubkey: DBC_PROGRAM_ID, + }, + ] + const claimDbcCreatorTradingFeeDisc = DynamicBondingCurveIDL.instructions.find(instruction => instruction.name === "claim_creator_trading_fee").discriminator; + const payload = Buffer.concat([Buffer.from(claimDbcCreatorTradingFeeDisc), U64_MAX.toBuffer(), U64_MAX.toBuffer()]) + await fundByClaimingFee(svm, signer, feeVault, tokenVault, remainingAccounts, payload, DBC_PROGRAM_ID); +} + +export async function claimDbcPartnerTradingFee( + svm: LiteSVM, + signer: Keypair, + feeClaimer: Keypair, + feeVault: PublicKey, + tokenVault: PublicKey, + poolConfig: PublicKey, + virtualPool: PublicKey +) { + const virtualPoolState = getVirtualPoolState(svm, virtualPool); + const poolConfigState = getVirtualConfigState(svm, poolConfig); + + const tokenAAccount = getOrCreateAtA( + svm, + feeClaimer, + virtualPoolState.baseMint, + feeClaimer.publicKey, + TOKEN_2022_PROGRAM_ID + ); + + const remainingAccounts = [ + { + isSigner: false, + isWritable: false, + pubkey: deriveDbcPoolAuthority(), + }, + { + isSigner: false, + isWritable: true, + pubkey: poolConfig, + }, + { + isSigner: false, + isWritable: true, + pubkey: virtualPool, + }, + { + isSigner: false, + isWritable: true, + pubkey: tokenAAccount, + }, + { + isSigner: false, + isWritable: true, + pubkey: tokenVault, + }, + + { + isSigner: false, + isWritable: true, + pubkey: virtualPoolState.baseVault, + }, + { + isSigner: false, + isWritable: true, + pubkey: virtualPoolState.quoteVault, + }, + { + isSigner: false, + isWritable: false, + pubkey: virtualPoolState.baseMint, + }, + { + isSigner: false, + isWritable: false, + pubkey: poolConfigState.quoteMint, + }, + + { + isSigner: false, + isWritable: true, + pubkey: feeVault, + }, + { + isSigner: false, + isWritable: false, + pubkey: TOKEN_2022_PROGRAM_ID, + }, + { + isSigner: false, + isWritable: false, + pubkey: TOKEN_PROGRAM_ID, + }, + { + isSigner: false, + isWritable: false, + pubkey: deriveDbcEventAuthority(), + }, + { + isSigner: false, + isWritable: false, + pubkey: DBC_PROGRAM_ID, + }, + ] + const claimDbcPartnerTradingFeeDisc = DynamicBondingCurveIDL.instructions.find(instruction => instruction.name === "claim_trading_fee").discriminator; + const payload = Buffer.concat([Buffer.from(claimDbcPartnerTradingFeeDisc), U64_MAX.toBuffer(), U64_MAX.toBuffer()]) + await fundByClaimingFee(svm, signer, feeVault, tokenVault, remainingAccounts, payload, DBC_PROGRAM_ID); +} + +export async function withdrawDbcCreatorSurplus( + svm: LiteSVM, + signer: Keypair, + feeVault: PublicKey, + tokenVault: PublicKey, + poolConfig: PublicKey, + virtualPool: PublicKey +) { + const virtualPoolState = getVirtualPoolState(svm, virtualPool); + const poolConfigState = getVirtualConfigState(svm, poolConfig); + + const remainingAccounts = [ + { + isSigner: false, + isWritable: false, + pubkey: deriveDbcPoolAuthority(), + }, + { + isSigner: false, + isWritable: true, + pubkey: poolConfig, + }, + { + isSigner: false, + isWritable: true, + pubkey: virtualPool, + }, + { + isSigner: false, + isWritable: true, + pubkey: tokenVault, + }, + { + isSigner: false, + isWritable: true, + pubkey: virtualPoolState.quoteVault, + }, + { + isSigner: false, + isWritable: false, + pubkey: poolConfigState.quoteMint, + }, + { + isSigner: false, + isWritable: true, + pubkey: feeVault, + }, + { + isSigner: false, + isWritable: false, + pubkey: TOKEN_PROGRAM_ID, + }, + { + isSigner: false, + isWritable: false, + pubkey: deriveDbcEventAuthority(), + }, + { + isSigner: false, + isWritable: false, + pubkey: DBC_PROGRAM_ID, + }, + ] + const creatorWithdrawSurplusDisc = DynamicBondingCurveIDL.instructions.find(instruction => instruction.name === "creator_withdraw_surplus").discriminator; + const payload = Buffer.from(creatorWithdrawSurplusDisc) + await fundByClaimingFee(svm, signer, feeVault, tokenVault, remainingAccounts, payload, DBC_PROGRAM_ID); +} + +export async function withdrawDbcPartnerSurplus( + svm: LiteSVM, + signer: Keypair, + feeVault: PublicKey, + tokenVault: PublicKey, + poolConfig: PublicKey, + virtualPool: PublicKey +) { + const virtualPoolState = getVirtualPoolState(svm, virtualPool); + const poolConfigState = getVirtualConfigState(svm, poolConfig); + + const remainingAccounts = [ + { + isSigner: false, + isWritable: false, + pubkey: deriveDbcPoolAuthority(), + }, + { + isSigner: false, + isWritable: true, + pubkey: poolConfig, + }, + { + isSigner: false, + isWritable: true, + pubkey: virtualPool, + }, + { + isSigner: false, + isWritable: true, + pubkey: tokenVault, + }, + { + isSigner: false, + isWritable: true, + pubkey: virtualPoolState.quoteVault, + }, + { + isSigner: false, + isWritable: false, + pubkey: poolConfigState.quoteMint, + }, + { + isSigner: false, + isWritable: true, + pubkey: feeVault, + }, + { + isSigner: false, + isWritable: false, + pubkey: TOKEN_PROGRAM_ID, + }, + { + isSigner: false, + isWritable: false, + pubkey: deriveDbcEventAuthority(), + }, + { + isSigner: false, + isWritable: false, + pubkey: DBC_PROGRAM_ID, + }, + ] + const partnerWithdrawSurplusDisc = DynamicBondingCurveIDL.instructions.find(instruction => instruction.name === "partner_withdraw_surplus").discriminator; + const payload = Buffer.from(partnerWithdrawSurplusDisc) + await fundByClaimingFee(svm, signer, feeVault, tokenVault, remainingAccounts, payload, DBC_PROGRAM_ID); +} + +export async function withdrawMigrationFee( + svm: LiteSVM, + signer: Keypair, + feeVault: PublicKey, + tokenVault: PublicKey, + poolConfig: PublicKey, + virtualPool: PublicKey, + isPartner: number, // 0 as partner and 1 as creator +) { + const virtualPoolState = getVirtualPoolState(svm, virtualPool); + const poolConfigState = getVirtualConfigState(svm, poolConfig); + + const remainingAccounts = [ + { + isSigner: false, + isWritable: false, + pubkey: deriveDbcPoolAuthority(), + }, + { + isSigner: false, + isWritable: true, + pubkey: poolConfig, + }, + { + isSigner: false, + isWritable: true, + pubkey: virtualPool, + }, + { + isSigner: false, + isWritable: true, + pubkey: tokenVault, + }, + { + isSigner: false, + isWritable: true, + pubkey: virtualPoolState.quoteVault, + }, + { + isSigner: false, + isWritable: false, + pubkey: poolConfigState.quoteMint, + }, + { + isSigner: false, + isWritable: true, + pubkey: feeVault, + }, + { + isSigner: false, + isWritable: false, + pubkey: TOKEN_PROGRAM_ID, + }, + { + isSigner: false, + isWritable: false, + pubkey: deriveDbcEventAuthority(), + }, + { + isSigner: false, + isWritable: false, + pubkey: DBC_PROGRAM_ID, + }, + ] + const withdrawMigrationFeeDisc = DynamicBondingCurveIDL.instructions.find(instruction => instruction.name === "withdraw_migration_fee").discriminator; + const payload = Buffer.concat([Buffer.from(withdrawMigrationFeeDisc), Buffer.from([isPartner])]) + await fundByClaimingFee(svm, signer, feeVault, tokenVault, remainingAccounts, payload, DBC_PROGRAM_ID); +} diff --git a/tests/common/idl/damm_v2.ts b/tests/common/idl/damm_v2.ts new file mode 100644 index 0000000..b0b288c --- /dev/null +++ b/tests/common/idl/damm_v2.ts @@ -0,0 +1,5571 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/cp_amm.json`. + */ +export type CpAmm = { + address: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"; + metadata: { + name: "cpAmm"; + version: "0.1.3"; + spec: "0.1.0"; + description: "Created with Anchor"; + }; + instructions: [ + { + name: "addLiquidity"; + discriminator: [181, 157, 89, 67, 143, 182, 52, 72]; + accounts: [ + { + name: "pool"; + writable: true; + relations: ["position"]; + }, + { + name: "position"; + writable: true; + }, + { + name: "tokenAAccount"; + docs: ["The user token a account"]; + writable: true; + }, + { + name: "tokenBAccount"; + docs: ["The user token b account"]; + writable: true; + }, + { + name: "tokenAVault"; + docs: ["The vault token account for input token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "tokenBVault"; + docs: ["The vault token account for output token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "tokenAMint"; + docs: ["The mint of token a"]; + relations: ["pool"]; + }, + { + name: "tokenBMint"; + docs: ["The mint of token b"]; + relations: ["pool"]; + }, + { + name: "positionNftAccount"; + docs: ["The token account for nft"]; + }, + { + name: "owner"; + docs: ["owner of position"]; + signer: true; + }, + { + name: "tokenAProgram"; + docs: ["Token a program"]; + }, + { + name: "tokenBProgram"; + docs: ["Token b program"]; + }, + { + 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: "addLiquidityParameters"; + }; + }; + } + ]; + }, + { + name: "claimPartnerFee"; + discriminator: [97, 206, 39, 105, 94, 94, 126, 148]; + accounts: [ + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "pool"; + writable: true; + }, + { + name: "tokenAAccount"; + docs: ["The treasury token a account"]; + writable: true; + }, + { + name: "tokenBAccount"; + docs: ["The treasury token b account"]; + writable: true; + }, + { + name: "tokenAVault"; + docs: ["The vault token account for input token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "tokenBVault"; + docs: ["The vault token account for output token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "tokenAMint"; + docs: ["The mint of token a"]; + relations: ["pool"]; + }, + { + name: "tokenBMint"; + docs: ["The mint of token b"]; + relations: ["pool"]; + }, + { + name: "partner"; + signer: true; + relations: ["pool"]; + }, + { + name: "tokenAProgram"; + docs: ["Token a program"]; + }, + { + name: "tokenBProgram"; + docs: ["Token b program"]; + }, + { + 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: "maxAmountA"; + type: "u64"; + }, + { + name: "maxAmountB"; + type: "u64"; + } + ]; + }, + { + name: "claimPositionFee"; + discriminator: [180, 38, 154, 17, 133, 33, 162, 211]; + accounts: [ + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "pool"; + relations: ["position"]; + }, + { + name: "position"; + writable: true; + }, + { + name: "tokenAAccount"; + docs: ["The user token a account"]; + writable: true; + }, + { + name: "tokenBAccount"; + docs: ["The user token b account"]; + writable: true; + }, + { + name: "tokenAVault"; + docs: ["The vault token account for input token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "tokenBVault"; + docs: ["The vault token account for output token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "tokenAMint"; + docs: ["The mint of token a"]; + relations: ["pool"]; + }, + { + name: "tokenBMint"; + docs: ["The mint of token b"]; + relations: ["pool"]; + }, + { + name: "positionNftAccount"; + docs: ["The token account for nft"]; + }, + { + name: "owner"; + docs: ["owner of position"]; + signer: true; + }, + { + name: "tokenAProgram"; + docs: ["Token a program"]; + }, + { + name: "tokenBProgram"; + docs: ["Token b program"]; + }, + { + 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: "claimProtocolFee"; + discriminator: [165, 228, 133, 48, 99, 249, 255, 33]; + accounts: [ + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "pool"; + writable: true; + }, + { + name: "tokenAVault"; + docs: ["The vault token account for input token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "tokenBVault"; + docs: ["The vault token account for output token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "tokenAMint"; + docs: ["The mint of token a"]; + relations: ["pool"]; + }, + { + name: "tokenBMint"; + docs: ["The mint of token b"]; + relations: ["pool"]; + }, + { + 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"; + docs: ["Claim fee operator"]; + }, + { + name: "operator"; + docs: ["Operator"]; + signer: true; + relations: ["claimFeeOperator"]; + }, + { + name: "tokenAProgram"; + docs: ["Token a program"]; + }, + { + name: "tokenBProgram"; + docs: ["Token b program"]; + }, + { + 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: "maxAmountA"; + type: "u64"; + }, + { + name: "maxAmountB"; + type: "u64"; + } + ]; + }, + { + name: "claimReward"; + discriminator: [149, 95, 181, 242, 94, 90, 158, 162]; + accounts: [ + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "pool"; + writable: true; + relations: ["position"]; + }, + { + name: "position"; + writable: true; + }, + { + name: "rewardVault"; + docs: ["The vault token account for reward token"]; + writable: true; + }, + { + name: "rewardMint"; + }, + { + name: "userTokenAccount"; + writable: true; + }, + { + name: "positionNftAccount"; + docs: ["The token account for nft"]; + }, + { + name: "owner"; + docs: ["owner of position"]; + signer: true; + }, + { + name: "tokenProgram"; + }, + { + 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: "rewardIndex"; + type: "u8"; + }, + { + name: "skipReward"; + type: "u8"; + } + ]; + }, + { + name: "closeClaimFeeOperator"; + discriminator: [38, 134, 82, 216, 95, 124, 17, 99]; + accounts: [ + { + name: "claimFeeOperator"; + writable: true; + }, + { + name: "rentReceiver"; + writable: true; + }, + { + name: "admin"; + 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: "closeConfig"; + discriminator: [145, 9, 72, 157, 95, 125, 61, 85]; + accounts: [ + { + name: "config"; + writable: true; + }, + { + name: "admin"; + writable: true; + signer: true; + }, + { + name: "rentReceiver"; + writable: true; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: []; + }, + { + name: "closePosition"; + discriminator: [123, 134, 81, 0, 49, 68, 98, 98]; + accounts: [ + { + name: "positionNftMint"; + docs: ["positionNftMint"]; + writable: true; + }, + { + name: "positionNftAccount"; + docs: ["The token account for nft"]; + writable: true; + }, + { + name: "pool"; + writable: true; + relations: ["position"]; + }, + { + name: "position"; + writable: true; + }, + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "rentReceiver"; + writable: true; + }, + { + name: "owner"; + docs: ["Owner of position"]; + signer: true; + }, + { + name: "tokenProgram"; + docs: [ + "Program to create NFT mint/token account and transfer for token22 account" + ]; + address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"; + }, + { + 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: "closeTokenBadge"; + discriminator: [108, 146, 86, 110, 179, 254, 10, 104]; + accounts: [ + { + name: "tokenBadge"; + writable: true; + }, + { + name: "admin"; + writable: true; + signer: true; + }, + { + name: "rentReceiver"; + writable: true; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: []; + }, + { + name: "createClaimFeeOperator"; + discriminator: [169, 62, 207, 107, 58, 187, 162, 109]; + accounts: [ + { + name: "claimFeeOperator"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [99, 102, 95, 111, 112, 101, 114, 97, 116, 111, 114]; + }, + { + kind: "account"; + path: "operator"; + } + ]; + }; + }, + { + name: "operator"; + }, + { + name: "admin"; + writable: true; + signer: true; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: []; + }, + { + name: "createConfig"; + docs: ["ADMIN FUNCTIONS /////"]; + discriminator: [201, 207, 243, 114, 75, 111, 47, 189]; + accounts: [ + { + name: "config"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [99, 111, 110, 102, 105, 103]; + }, + { + kind: "arg"; + path: "index"; + } + ]; + }; + }, + { + name: "admin"; + writable: true; + signer: true; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: [ + { + name: "index"; + type: "u64"; + }, + { + name: "configParameters"; + type: { + defined: { + name: "staticConfigParameters"; + }; + }; + } + ]; + }, + { + name: "createDynamicConfig"; + discriminator: [81, 251, 122, 78, 66, 57, 208, 82]; + accounts: [ + { + name: "config"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [99, 111, 110, 102, 105, 103]; + }, + { + kind: "arg"; + path: "index"; + } + ]; + }; + }, + { + name: "admin"; + writable: true; + signer: true; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: [ + { + name: "index"; + type: "u64"; + }, + { + name: "configParameters"; + type: { + defined: { + name: "dynamicConfigParameters"; + }; + }; + } + ]; + }, + { + name: "createPosition"; + discriminator: [48, 215, 197, 153, 96, 203, 180, 133]; + accounts: [ + { + name: "owner"; + }, + { + name: "positionNftMint"; + docs: ["positionNftMint"]; + writable: true; + signer: true; + }, + { + name: "positionNftAccount"; + 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 + ]; + }, + { + kind: "account"; + path: "positionNftMint"; + } + ]; + }; + }, + { + name: "pool"; + writable: true; + }, + { + name: "position"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [112, 111, 115, 105, 116, 105, 111, 110]; + }, + { + kind: "account"; + path: "positionNftMint"; + } + ]; + }; + }, + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "payer"; + docs: ["Address paying to create the position. Can be anyone"]; + writable: true; + signer: true; + }, + { + name: "tokenProgram"; + docs: [ + "Program to create NFT mint/token account and transfer for token22 account" + ]; + address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: []; + }, + { + name: "createTokenBadge"; + discriminator: [88, 206, 0, 91, 60, 175, 151, 118]; + accounts: [ + { + name: "tokenBadge"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [116, 111, 107, 101, 110, 95, 98, 97, 100, 103, 101]; + }, + { + kind: "account"; + path: "tokenMint"; + } + ]; + }; + }, + { + name: "tokenMint"; + }, + { + name: "admin"; + writable: true; + signer: true; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: []; + }, + { + name: "fundReward"; + discriminator: [188, 50, 249, 165, 93, 151, 38, 63]; + accounts: [ + { + name: "pool"; + writable: true; + }, + { + name: "rewardVault"; + writable: true; + }, + { + name: "rewardMint"; + }, + { + name: "funderTokenAccount"; + writable: true; + }, + { + name: "funder"; + signer: true; + }, + { + name: "tokenProgram"; + }, + { + 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: "rewardIndex"; + type: "u8"; + }, + { + name: "amount"; + type: "u64"; + }, + { + name: "carryForward"; + type: "bool"; + } + ]; + }, + { + name: "initializeCustomizablePool"; + discriminator: [20, 161, 241, 24, 189, 221, 180, 2]; + accounts: [ + { + name: "creator"; + }, + { + name: "positionNftMint"; + docs: ["positionNftMint"]; + writable: true; + signer: true; + }, + { + name: "positionNftAccount"; + 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 + ]; + }, + { + kind: "account"; + path: "positionNftMint"; + } + ]; + }; + }, + { + name: "payer"; + docs: ["Address paying to create the pool. Can be anyone"]; + writable: true; + signer: true; + }, + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "pool"; + docs: ["Initialize an account to store the pool state"]; + writable: true; + }, + { + name: "position"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [112, 111, 115, 105, 116, 105, 111, 110]; + }, + { + kind: "account"; + path: "positionNftMint"; + } + ]; + }; + }, + { + name: "tokenAMint"; + docs: ["Token a mint"]; + }, + { + name: "tokenBMint"; + docs: ["Token b mint"]; + }, + { + name: "tokenAVault"; + 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]; + }, + { + kind: "account"; + path: "tokenAMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "tokenBVault"; + 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]; + }, + { + kind: "account"; + path: "tokenBMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "payerTokenA"; + docs: ["payer token a account"]; + writable: true; + }, + { + name: "payerTokenB"; + docs: ["creator token b account"]; + writable: true; + }, + { + name: "tokenAProgram"; + docs: ["Program to create mint account and mint tokens"]; + }, + { + name: "tokenBProgram"; + docs: ["Program to create mint account and mint tokens"]; + }, + { + name: "token2022Program"; + docs: [ + "Program to create NFT mint/token account and transfer for token22 account" + ]; + address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: [ + { + name: "params"; + type: { + defined: { + name: "initializeCustomizablePoolParameters"; + }; + }; + } + ]; + }, + { + name: "initializePool"; + docs: ["USER FUNCTIONS ////"]; + discriminator: [95, 180, 10, 172, 84, 174, 232, 40]; + accounts: [ + { + name: "creator"; + }, + { + name: "positionNftMint"; + docs: ["positionNftMint"]; + writable: true; + signer: true; + }, + { + name: "positionNftAccount"; + 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 + ]; + }, + { + kind: "account"; + path: "positionNftMint"; + } + ]; + }; + }, + { + name: "payer"; + docs: ["Address paying to create the pool. Can be anyone"]; + writable: true; + signer: true; + }, + { + name: "config"; + docs: ["Which config the pool belongs to."]; + }, + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "pool"; + docs: ["Initialize an account to store the pool state"]; + writable: true; + }, + { + name: "position"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [112, 111, 115, 105, 116, 105, 111, 110]; + }, + { + kind: "account"; + path: "positionNftMint"; + } + ]; + }; + }, + { + name: "tokenAMint"; + docs: ["Token a mint"]; + }, + { + name: "tokenBMint"; + docs: ["Token b mint"]; + }, + { + name: "tokenAVault"; + 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]; + }, + { + kind: "account"; + path: "tokenAMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "tokenBVault"; + 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]; + }, + { + kind: "account"; + path: "tokenBMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "payerTokenA"; + docs: ["payer token a account"]; + writable: true; + }, + { + name: "payerTokenB"; + docs: ["creator token b account"]; + writable: true; + }, + { + name: "tokenAProgram"; + docs: ["Program to create mint account and mint tokens"]; + }, + { + name: "tokenBProgram"; + docs: ["Program to create mint account and mint tokens"]; + }, + { + name: "token2022Program"; + docs: [ + "Program to create NFT mint/token account and transfer for token22 account" + ]; + address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: [ + { + name: "params"; + type: { + defined: { + name: "initializePoolParameters"; + }; + }; + } + ]; + }, + { + name: "initializePoolWithDynamicConfig"; + discriminator: [149, 82, 72, 197, 253, 252, 68, 15]; + accounts: [ + { + name: "creator"; + }, + { + name: "positionNftMint"; + docs: ["positionNftMint"]; + writable: true; + signer: true; + }, + { + name: "positionNftAccount"; + 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 + ]; + }, + { + kind: "account"; + path: "positionNftMint"; + } + ]; + }; + }, + { + name: "payer"; + docs: ["Address paying to create the pool. Can be anyone"]; + writable: true; + signer: true; + }, + { + name: "poolCreatorAuthority"; + signer: true; + relations: ["config"]; + }, + { + name: "config"; + docs: ["Which config the pool belongs to."]; + }, + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "pool"; + docs: ["Initialize an account to store the pool state"]; + writable: true; + }, + { + name: "position"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [112, 111, 115, 105, 116, 105, 111, 110]; + }, + { + kind: "account"; + path: "positionNftMint"; + } + ]; + }; + }, + { + name: "tokenAMint"; + docs: ["Token a mint"]; + }, + { + name: "tokenBMint"; + docs: ["Token b mint"]; + }, + { + name: "tokenAVault"; + 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]; + }, + { + kind: "account"; + path: "tokenAMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "tokenBVault"; + 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]; + }, + { + kind: "account"; + path: "tokenBMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "payerTokenA"; + docs: ["payer token a account"]; + writable: true; + }, + { + name: "payerTokenB"; + docs: ["creator token b account"]; + writable: true; + }, + { + name: "tokenAProgram"; + docs: ["Program to create mint account and mint tokens"]; + }, + { + name: "tokenBProgram"; + docs: ["Program to create mint account and mint tokens"]; + }, + { + name: "token2022Program"; + docs: [ + "Program to create NFT mint/token account and transfer for token22 account" + ]; + address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: [ + { + name: "params"; + type: { + defined: { + name: "initializeCustomizablePoolParameters"; + }; + }; + } + ]; + }, + { + name: "initializeReward"; + discriminator: [95, 135, 192, 196, 242, 129, 230, 68]; + accounts: [ + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "pool"; + writable: true; + }, + { + name: "rewardVault"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 114, + 101, + 119, + 97, + 114, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ]; + }, + { + kind: "account"; + path: "pool"; + }, + { + kind: "arg"; + path: "rewardIndex"; + } + ]; + }; + }, + { + name: "rewardMint"; + }, + { + name: "signer"; + signer: true; + }, + { + name: "payer"; + writable: true; + signer: true; + }, + { + name: "tokenProgram"; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: [ + { + name: "rewardIndex"; + type: "u8"; + }, + { + name: "rewardDuration"; + type: "u64"; + }, + { + name: "funder"; + type: "pubkey"; + } + ]; + }, + { + name: "lockPosition"; + discriminator: [227, 62, 2, 252, 247, 10, 171, 185]; + accounts: [ + { + name: "pool"; + relations: ["position"]; + }, + { + name: "position"; + writable: true; + }, + { + name: "vesting"; + writable: true; + signer: true; + }, + { + name: "positionNftAccount"; + docs: ["The token account for nft"]; + }, + { + name: "owner"; + docs: ["owner of position"]; + signer: true; + }, + { + name: "payer"; + writable: true; + signer: true; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: [ + { + name: "params"; + type: { + defined: { + name: "vestingParameters"; + }; + }; + } + ]; + }, + { + name: "permanentLockPosition"; + discriminator: [165, 176, 125, 6, 231, 171, 186, 213]; + accounts: [ + { + name: "pool"; + writable: true; + relations: ["position"]; + }, + { + name: "position"; + writable: true; + }, + { + name: "positionNftAccount"; + docs: ["The token account for nft"]; + }, + { + name: "owner"; + docs: ["owner of position"]; + 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: "permanentLockLiquidity"; + type: "u128"; + } + ]; + }, + { + name: "refreshVesting"; + discriminator: [9, 94, 216, 14, 116, 204, 247, 0]; + accounts: [ + { + name: "pool"; + relations: ["position"]; + }, + { + name: "position"; + writable: true; + }, + { + name: "positionNftAccount"; + docs: ["The token account for nft"]; + }, + { + name: "owner"; + } + ]; + args: []; + }, + { + name: "removeAllLiquidity"; + discriminator: [10, 51, 61, 35, 112, 105, 24, 85]; + accounts: [ + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "pool"; + writable: true; + relations: ["position"]; + }, + { + name: "position"; + writable: true; + }, + { + name: "tokenAAccount"; + docs: ["The user token a account"]; + writable: true; + }, + { + name: "tokenBAccount"; + docs: ["The user token b account"]; + writable: true; + }, + { + name: "tokenAVault"; + docs: ["The vault token account for input token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "tokenBVault"; + docs: ["The vault token account for output token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "tokenAMint"; + docs: ["The mint of token a"]; + relations: ["pool"]; + }, + { + name: "tokenBMint"; + docs: ["The mint of token b"]; + relations: ["pool"]; + }, + { + name: "positionNftAccount"; + docs: ["The token account for nft"]; + }, + { + name: "owner"; + docs: ["owner of position"]; + signer: true; + }, + { + name: "tokenAProgram"; + docs: ["Token a program"]; + }, + { + name: "tokenBProgram"; + docs: ["Token b program"]; + }, + { + 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: "tokenAAmountThreshold"; + type: "u64"; + }, + { + name: "tokenBAmountThreshold"; + type: "u64"; + } + ]; + }, + { + name: "removeLiquidity"; + discriminator: [80, 85, 209, 72, 24, 206, 177, 108]; + accounts: [ + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "pool"; + writable: true; + relations: ["position"]; + }, + { + name: "position"; + writable: true; + }, + { + name: "tokenAAccount"; + docs: ["The user token a account"]; + writable: true; + }, + { + name: "tokenBAccount"; + docs: ["The user token b account"]; + writable: true; + }, + { + name: "tokenAVault"; + docs: ["The vault token account for input token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "tokenBVault"; + docs: ["The vault token account for output token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "tokenAMint"; + docs: ["The mint of token a"]; + relations: ["pool"]; + }, + { + name: "tokenBMint"; + docs: ["The mint of token b"]; + relations: ["pool"]; + }, + { + name: "positionNftAccount"; + docs: ["The token account for nft"]; + }, + { + name: "owner"; + docs: ["owner of position"]; + signer: true; + }, + { + name: "tokenAProgram"; + docs: ["Token a program"]; + }, + { + name: "tokenBProgram"; + docs: ["Token b program"]; + }, + { + 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: "removeLiquidityParameters"; + }; + }; + } + ]; + }, + { + name: "setPoolStatus"; + discriminator: [112, 87, 135, 223, 83, 204, 132, 53]; + accounts: [ + { + name: "pool"; + writable: true; + }, + { + name: "admin"; + 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: "status"; + type: "u8"; + } + ]; + }, + { + name: "splitPosition"; + discriminator: [172, 241, 221, 138, 161, 29, 253, 42]; + accounts: [ + { + name: "pool"; + writable: true; + relations: ["firstPosition", "secondPosition"]; + }, + { + name: "firstPosition"; + docs: ["The first position"]; + writable: true; + }, + { + name: "firstPositionNftAccount"; + docs: ["The token account for position nft"]; + }, + { + name: "secondPosition"; + docs: ["The second position"]; + writable: true; + }, + { + name: "secondPositionNftAccount"; + docs: ["The token account for position nft"]; + }, + { + name: "firstOwner"; + docs: ["Owner of first position"]; + signer: true; + }, + { + name: "secondOwner"; + docs: ["Owner of second position"]; + 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: "splitPositionParameters"; + }; + }; + } + ]; + }, + { + name: "swap"; + discriminator: [248, 198, 158, 145, 225, 117, 135, 200]; + accounts: [ + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "pool"; + docs: ["Pool account"]; + writable: true; + }, + { + name: "inputTokenAccount"; + docs: ["The user token account for input token"]; + writable: true; + }, + { + name: "outputTokenAccount"; + docs: ["The user token account for output token"]; + writable: true; + }, + { + name: "tokenAVault"; + docs: ["The vault token account for input token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "tokenBVault"; + docs: ["The vault token account for output token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "tokenAMint"; + docs: ["The mint of token a"]; + }, + { + name: "tokenBMint"; + docs: ["The mint of token b"]; + }, + { + name: "payer"; + docs: ["The user performing the swap"]; + signer: true; + }, + { + name: "tokenAProgram"; + docs: ["Token a program"]; + }, + { + name: "tokenBProgram"; + docs: ["Token b program"]; + }, + { + name: "referralTokenAccount"; + docs: ["referral token account"]; + writable: true; + optional: 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: "swapParameters"; + }; + }; + } + ]; + }, + { + name: "updateRewardDuration"; + discriminator: [138, 174, 196, 169, 213, 235, 254, 107]; + accounts: [ + { + name: "pool"; + writable: true; + }, + { + 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: "rewardIndex"; + type: "u8"; + }, + { + name: "newDuration"; + type: "u64"; + } + ]; + }, + { + name: "updateRewardFunder"; + discriminator: [211, 28, 48, 32, 215, 160, 35, 23]; + accounts: [ + { + name: "pool"; + writable: true; + }, + { + 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: "rewardIndex"; + type: "u8"; + }, + { + name: "newFunder"; + type: "pubkey"; + } + ]; + }, + { + name: "withdrawIneligibleReward"; + discriminator: [148, 206, 42, 195, 247, 49, 103, 8]; + accounts: [ + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, + { + name: "pool"; + writable: true; + }, + { + name: "rewardVault"; + writable: true; + }, + { + name: "rewardMint"; + }, + { + name: "funderTokenAccount"; + writable: true; + }, + { + name: "funder"; + signer: true; + }, + { + name: "tokenProgram"; + }, + { + 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: "rewardIndex"; + 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: "evtClaimPositionFee"; + discriminator: [198, 182, 183, 52, 97, 12, 49, 56]; + }, + { + name: "evtClaimProtocolFee"; + 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]; + }, + { + name: "evtCloseConfig"; + 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]; + }, + { + name: "evtCreateConfig"; + discriminator: [131, 207, 180, 174, 180, 73, 165, 54]; + }, + { + name: "evtCreateDynamicConfig"; + discriminator: [231, 197, 13, 164, 248, 213, 133, 152]; + }, + { + name: "evtCreatePosition"; + discriminator: [156, 15, 119, 198, 29, 181, 221, 55]; + }, + { + name: "evtCreateTokenBadge"; + discriminator: [141, 120, 134, 116, 34, 28, 114, 160]; + }, + { + name: "evtFundReward"; + discriminator: [104, 233, 237, 122, 199, 191, 121, 85]; + }, + { + name: "evtInitializePool"; + discriminator: [228, 50, 246, 85, 203, 66, 134, 37]; + }, + { + name: "evtInitializeReward"; + discriminator: [129, 91, 188, 3, 246, 52, 185, 249]; + }, + { + name: "evtLockPosition"; + 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]; + }, + { + name: "evtSetPoolStatus"; + discriminator: [100, 213, 74, 3, 95, 91, 228, 146]; + }, + { + name: "evtSplitPosition"; + discriminator: [182, 138, 42, 254, 27, 94, 82, 221]; + }, + { + name: "evtSwap"; + discriminator: [27, 60, 21, 213, 138, 170, 187, 147]; + }, + { + name: "evtUpdateRewardDuration"; + discriminator: [149, 135, 65, 231, 129, 153, 65, 57]; + }, + { + name: "evtUpdateRewardFunder"; + discriminator: [76, 154, 208, 13, 40, 115, 246, 146]; + }, + { + name: "evtWithdrawIneligibleReward"; + discriminator: [248, 215, 184, 78, 31, 180, 179, 168]; + } + ]; + errors: [ + { + code: 6000; + name: "mathOverflow"; + msg: "Math operation overflow"; + }, + { + code: 6001; + name: "invalidFee"; + msg: "Invalid fee setup"; + }, + { + code: 6002; + name: "exceededSlippage"; + msg: "Exceeded slippage tolerance"; + }, + { + code: 6003; + name: "poolDisabled"; + msg: "Pool disabled"; + }, + { + code: 6004; + name: "exceedMaxFeeBps"; + msg: "Exceeded max fee bps"; + }, + { + code: 6005; + name: "invalidAdmin"; + msg: "Invalid admin"; + }, + { + code: 6006; + name: "amountIsZero"; + msg: "Amount is zero"; + }, + { + code: 6007; + name: "typeCastFailed"; + msg: "Type cast error"; + }, + { + code: 6008; + name: "unableToModifyActivationPoint"; + msg: "Unable to modify activation point"; + }, + { + code: 6009; + name: "invalidAuthorityToCreateThePool"; + msg: "Invalid authority to create the pool"; + }, + { + code: 6010; + name: "invalidActivationType"; + msg: "Invalid activation type"; + }, + { + code: 6011; + name: "invalidActivationPoint"; + msg: "Invalid activation point"; + }, + { + code: 6012; + name: "invalidQuoteMint"; + msg: "Quote token must be SOL,USDC"; + }, + { + code: 6013; + name: "invalidFeeCurve"; + msg: "Invalid fee curve"; + }, + { + code: 6014; + name: "invalidPriceRange"; + msg: "Invalid Price Range"; + }, + { + code: 6015; + name: "priceRangeViolation"; + msg: "Trade is over price range"; + }, + { + code: 6016; + name: "invalidParameters"; + msg: "Invalid parameters"; + }, + { + code: 6017; + name: "invalidCollectFeeMode"; + msg: "Invalid collect fee mode"; + }, + { + code: 6018; + name: "invalidInput"; + msg: "Invalid input"; + }, + { + code: 6019; + name: "cannotCreateTokenBadgeOnSupportedMint"; + msg: "Cannot create token badge on supported mint"; + }, + { + code: 6020; + name: "invalidTokenBadge"; + msg: "Invalid token badge"; + }, + { + code: 6021; + name: "invalidMinimumLiquidity"; + msg: "Invalid minimum liquidity"; + }, + { + code: 6022; + name: "invalidVestingInfo"; + msg: "Invalid vesting information"; + }, + { + code: 6023; + name: "insufficientLiquidity"; + msg: "Insufficient liquidity"; + }, + { + code: 6024; + name: "invalidVestingAccount"; + msg: "Invalid vesting account"; + }, + { + code: 6025; + name: "invalidPoolStatus"; + msg: "Invalid pool status"; + }, + { + code: 6026; + name: "unsupportNativeMintToken2022"; + msg: "Unsupported native mint token2022"; + }, + { + code: 6027; + name: "invalidRewardIndex"; + msg: "Invalid reward index"; + }, + { + code: 6028; + name: "invalidRewardDuration"; + msg: "Invalid reward duration"; + }, + { + code: 6029; + name: "rewardInitialized"; + msg: "Reward already initialized"; + }, + { + code: 6030; + name: "rewardUninitialized"; + msg: "Reward not initialized"; + }, + { + code: 6031; + name: "invalidRewardVault"; + msg: "Invalid reward vault"; + }, + { + code: 6032; + name: "mustWithdrawnIneligibleReward"; + msg: "Must withdraw ineligible reward"; + }, + { + code: 6033; + name: "identicalRewardDuration"; + msg: "Reward duration is the same"; + }, + { + code: 6034; + name: "rewardCampaignInProgress"; + msg: "Reward campaign in progress"; + }, + { + code: 6035; + name: "identicalFunder"; + msg: "Identical funder"; + }, + { + code: 6036; + name: "invalidFunder"; + msg: "Invalid funder"; + }, + { + code: 6037; + name: "rewardNotEnded"; + msg: "Reward not ended"; + }, + { + code: 6038; + name: "feeInverseIsIncorrect"; + msg: "Fee inverse is incorrect"; + }, + { + code: 6039; + name: "positionIsNotEmpty"; + msg: "Position is not empty"; + }, + { + code: 6040; + name: "invalidPoolCreatorAuthority"; + msg: "Invalid pool creator authority"; + }, + { + code: 6041; + name: "invalidConfigType"; + msg: "Invalid config type"; + }, + { + code: 6042; + name: "invalidPoolCreator"; + msg: "Invalid pool creator"; + }, + { + code: 6043; + name: "rewardVaultFrozenSkipRequired"; + msg: "Reward vault is frozen, must skip reward to proceed"; + }, + { + code: 6044; + name: "invalidSplitPositionParameters"; + msg: "Invalid parameters for split position"; + }, + { + code: 6045; + name: "unsupportPositionHasVestingLock"; + msg: "Unsupported split position has vesting lock"; + }, + { + code: 6046; + name: "samePosition"; + msg: "Same position"; + } + ]; + types: [ + { + name: "addLiquidityParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "liquidityDelta"; + docs: ["delta liquidity"]; + type: "u128"; + }, + { + name: "tokenAAmountThreshold"; + docs: ["maximum token a amount"]; + type: "u64"; + }, + { + name: "tokenBAmountThreshold"; + docs: ["maximum token b amount"]; + type: "u64"; + } + ]; + }; + }, + { + name: "baseFeeConfig"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "cliffFeeNumerator"; + type: "u64"; + }, + { + name: "feeSchedulerMode"; + type: "u8"; + }, + { + name: "padding"; + type: { + array: ["u8", 5]; + }; + }, + { + name: "numberOfPeriod"; + type: "u16"; + }, + { + name: "periodFrequency"; + type: "u64"; + }, + { + name: "reductionFactor"; + type: "u64"; + } + ]; + }; + }, + { + name: "baseFeeParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "cliffFeeNumerator"; + type: "u64"; + }, + { + name: "numberOfPeriod"; + type: "u16"; + }, + { + name: "periodFrequency"; + type: "u64"; + }, + { + name: "reductionFactor"; + type: "u64"; + }, + { + name: "feeSchedulerMode"; + type: "u8"; + } + ]; + }; + }, + { + name: "baseFeeStruct"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "cliffFeeNumerator"; + type: "u64"; + }, + { + name: "feeSchedulerMode"; + type: "u8"; + }, + { + name: "padding0"; + type: { + array: ["u8", 5]; + }; + }, + { + name: "numberOfPeriod"; + type: "u16"; + }, + { + name: "periodFrequency"; + type: "u64"; + }, + { + name: "reductionFactor"; + type: "u64"; + }, + { + name: "padding1"; + type: "u64"; + } + ]; + }; + }, + { + name: "claimFeeOperator"; + docs: ["Parameter that set by the protocol"]; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "operator"; + docs: ["operator"]; + type: "pubkey"; + }, + { + name: "padding"; + docs: ["Reserve"]; + type: { + array: ["u8", 128]; + }; + } + ]; + }; + }, + { + name: "config"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "vaultConfigKey"; + docs: ["Vault config key"]; + type: "pubkey"; + }, + { + name: "poolCreatorAuthority"; + docs: [ + "Only pool_creator_authority can use the current config to initialize new pool. When it's Pubkey::default, it's a public config." + ]; + type: "pubkey"; + }, + { + name: "poolFees"; + docs: ["Pool fee"]; + type: { + defined: { + name: "poolFeesConfig"; + }; + }; + }, + { + name: "activationType"; + docs: ["Activation type"]; + type: "u8"; + }, + { + name: "collectFeeMode"; + docs: ["Collect fee mode"]; + type: "u8"; + }, + { + name: "configType"; + docs: ["Config type mode, 0 for static, 1 for dynamic"]; + type: "u8"; + }, + { + name: "padding0"; + docs: ["padding 0"]; + type: { + array: ["u8", 5]; + }; + }, + { + name: "index"; + docs: ["config index"]; + type: "u64"; + }, + { + name: "sqrtMinPrice"; + docs: ["sqrt min price"]; + type: "u128"; + }, + { + name: "sqrtMaxPrice"; + docs: ["sqrt max price"]; + type: "u128"; + }, + { + name: "padding1"; + docs: ["Fee curve point", "Padding for further use"]; + type: { + array: ["u64", 10]; + }; + } + ]; + }; + }, + { + name: "dynamicConfigParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "poolCreatorAuthority"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "dynamicFeeConfig"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "initialized"; + type: "u8"; + }, + { + name: "padding"; + type: { + array: ["u8", 7]; + }; + }, + { + name: "maxVolatilityAccumulator"; + type: "u32"; + }, + { + name: "variableFeeControl"; + type: "u32"; + }, + { + name: "binStep"; + type: "u16"; + }, + { + name: "filterPeriod"; + type: "u16"; + }, + { + name: "decayPeriod"; + type: "u16"; + }, + { + name: "reductionFactor"; + type: "u16"; + }, + { + name: "padding1"; + type: { + array: ["u8", 8]; + }; + }, + { + name: "binStepU128"; + type: "u128"; + } + ]; + }; + }, + { + name: "dynamicFeeParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "binStep"; + type: "u16"; + }, + { + name: "binStepU128"; + type: "u128"; + }, + { + name: "filterPeriod"; + type: "u16"; + }, + { + name: "decayPeriod"; + type: "u16"; + }, + { + name: "reductionFactor"; + type: "u16"; + }, + { + name: "maxVolatilityAccumulator"; + type: "u32"; + }, + { + name: "variableFeeControl"; + type: "u32"; + } + ]; + }; + }, + { + name: "dynamicFeeStruct"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "initialized"; + type: "u8"; + }, + { + name: "padding"; + type: { + array: ["u8", 7]; + }; + }, + { + name: "maxVolatilityAccumulator"; + type: "u32"; + }, + { + name: "variableFeeControl"; + type: "u32"; + }, + { + name: "binStep"; + type: "u16"; + }, + { + name: "filterPeriod"; + type: "u16"; + }, + { + name: "decayPeriod"; + type: "u16"; + }, + { + name: "reductionFactor"; + type: "u16"; + }, + { + name: "lastUpdateTimestamp"; + type: "u64"; + }, + { + name: "binStepU128"; + type: "u128"; + }, + { + name: "sqrtPriceReference"; + type: "u128"; + }, + { + name: "volatilityAccumulator"; + type: "u128"; + }, + { + name: "volatilityReference"; + type: "u128"; + } + ]; + }; + }, + { + 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: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "tokenAAmount"; + type: "u64"; + }, + { + name: "tokenBAmount"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtClaimPositionFee"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "position"; + type: "pubkey"; + }, + { + name: "owner"; + type: "pubkey"; + }, + { + name: "feeAClaimed"; + type: "u64"; + }, + { + name: "feeBClaimed"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtClaimProtocolFee"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "tokenAAmount"; + type: "u64"; + }, + { + name: "tokenBAmount"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtClaimReward"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "position"; + type: "pubkey"; + }, + { + name: "owner"; + type: "pubkey"; + }, + { + name: "mintReward"; + type: "pubkey"; + }, + { + name: "rewardIndex"; + type: "u8"; + }, + { + name: "totalReward"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtCloseClaimFeeOperator"; + docs: ["Close claim fee operator"]; + type: { + kind: "struct"; + fields: [ + { + name: "claimFeeOperator"; + type: "pubkey"; + }, + { + name: "operator"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtCloseConfig"; + docs: ["Close config"]; + type: { + kind: "struct"; + fields: [ + { + name: "config"; + docs: ["Config pubkey"]; + type: "pubkey"; + }, + { + name: "admin"; + docs: ["admin pk"]; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtClosePosition"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "owner"; + type: "pubkey"; + }, + { + name: "position"; + type: "pubkey"; + }, + { + name: "positionNftMint"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtCreateClaimFeeOperator"; + docs: ["Create claim fee operator"]; + type: { + kind: "struct"; + fields: [ + { + name: "operator"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtCreateConfig"; + docs: ["Create static config"]; + type: { + kind: "struct"; + fields: [ + { + name: "poolFees"; + type: { + defined: { + name: "poolFeeParameters"; + }; + }; + }, + { + name: "vaultConfigKey"; + type: "pubkey"; + }, + { + name: "poolCreatorAuthority"; + type: "pubkey"; + }, + { + name: "activationType"; + type: "u8"; + }, + { + name: "sqrtMinPrice"; + type: "u128"; + }, + { + name: "sqrtMaxPrice"; + type: "u128"; + }, + { + name: "collectFeeMode"; + type: "u8"; + }, + { + name: "index"; + type: "u64"; + }, + { + name: "config"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtCreateDynamicConfig"; + docs: ["Create dynamic config"]; + type: { + kind: "struct"; + fields: [ + { + name: "config"; + type: "pubkey"; + }, + { + name: "poolCreatorAuthority"; + type: "pubkey"; + }, + { + name: "index"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtCreatePosition"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "owner"; + type: "pubkey"; + }, + { + name: "position"; + type: "pubkey"; + }, + { + name: "positionNftMint"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtCreateTokenBadge"; + docs: ["Create token badge"]; + type: { + kind: "struct"; + fields: [ + { + name: "tokenMint"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtFundReward"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "funder"; + type: "pubkey"; + }, + { + name: "mintReward"; + type: "pubkey"; + }, + { + name: "rewardIndex"; + type: "u8"; + }, + { + name: "amount"; + type: "u64"; + }, + { + name: "transferFeeExcludedAmountIn"; + type: "u64"; + }, + { + name: "rewardDurationEnd"; + type: "u64"; + }, + { + name: "preRewardRate"; + type: "u128"; + }, + { + name: "postRewardRate"; + type: "u128"; + } + ]; + }; + }, + { + name: "evtInitializePool"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "tokenAMint"; + type: "pubkey"; + }, + { + name: "tokenBMint"; + type: "pubkey"; + }, + { + name: "creator"; + type: "pubkey"; + }, + { + name: "payer"; + type: "pubkey"; + }, + { + name: "alphaVault"; + type: "pubkey"; + }, + { + name: "poolFees"; + type: { + defined: { + name: "poolFeeParameters"; + }; + }; + }, + { + name: "sqrtMinPrice"; + type: "u128"; + }, + { + name: "sqrtMaxPrice"; + type: "u128"; + }, + { + name: "activationType"; + type: "u8"; + }, + { + name: "collectFeeMode"; + type: "u8"; + }, + { + name: "liquidity"; + type: "u128"; + }, + { + name: "sqrtPrice"; + type: "u128"; + }, + { + name: "activationPoint"; + type: "u64"; + }, + { + name: "tokenAFlag"; + type: "u8"; + }, + { + name: "tokenBFlag"; + type: "u8"; + }, + { + name: "tokenAAmount"; + type: "u64"; + }, + { + name: "tokenBAmount"; + type: "u64"; + }, + { + name: "totalAmountA"; + type: "u64"; + }, + { + name: "totalAmountB"; + type: "u64"; + }, + { + name: "poolType"; + type: "u8"; + } + ]; + }; + }, + { + name: "evtInitializeReward"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "rewardMint"; + type: "pubkey"; + }, + { + name: "funder"; + type: "pubkey"; + }, + { + name: "creator"; + type: "pubkey"; + }, + { + name: "rewardIndex"; + type: "u8"; + }, + { + name: "rewardDuration"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtLockPosition"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "position"; + type: "pubkey"; + }, + { + name: "owner"; + type: "pubkey"; + }, + { + name: "vesting"; + type: "pubkey"; + }, + { + name: "cliffPoint"; + type: "u64"; + }, + { + name: "periodFrequency"; + type: "u64"; + }, + { + name: "cliffUnlockLiquidity"; + type: "u128"; + }, + { + name: "liquidityPerPeriod"; + type: "u128"; + }, + { + name: "numberOfPeriod"; + type: "u16"; + } + ]; + }; + }, + { + name: "evtPermanentLockPosition"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "position"; + type: "pubkey"; + }, + { + name: "lockLiquidityAmount"; + type: "u128"; + }, + { + name: "totalPermanentLockedLiquidity"; + type: "u128"; + } + ]; + }; + }, + { + 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: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "status"; + type: "u8"; + } + ]; + }; + }, + { + name: "evtSplitPosition"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "firstOwner"; + type: "pubkey"; + }, + { + name: "secondOwner"; + type: "pubkey"; + }, + { + name: "firstPosition"; + type: "pubkey"; + }, + { + name: "secondPosition"; + type: "pubkey"; + }, + { + name: "currentSqrtPrice"; + type: "u128"; + }, + { + name: "amountSplits"; + type: { + defined: { + name: "splitAmountInfo"; + }; + }; + }, + { + name: "firstPositionInfo"; + type: { + defined: { + name: "splitPositionInfo"; + }; + }; + }, + { + name: "secondPositionInfo"; + type: { + defined: { + name: "splitPositionInfo"; + }; + }; + }, + { + name: "splitPositionParameters"; + type: { + defined: { + name: "splitPositionParameters"; + }; + }; + } + ]; + }; + }, + { + 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: "evtUpdateRewardDuration"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "rewardIndex"; + type: "u8"; + }, + { + name: "oldRewardDuration"; + type: "u64"; + }, + { + name: "newRewardDuration"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtUpdateRewardFunder"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "rewardIndex"; + type: "u8"; + }, + { + name: "oldFunder"; + type: "pubkey"; + }, + { + name: "newFunder"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtWithdrawIneligibleReward"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "rewardMint"; + type: "pubkey"; + }, + { + name: "amount"; + type: "u64"; + } + ]; + }; + }, + { + name: "initializeCustomizablePoolParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "poolFees"; + docs: ["pool fees"]; + type: { + defined: { + name: "poolFeeParameters"; + }; + }; + }, + { + name: "sqrtMinPrice"; + docs: ["sqrt min price"]; + type: "u128"; + }, + { + name: "sqrtMaxPrice"; + docs: ["sqrt max price"]; + type: "u128"; + }, + { + name: "hasAlphaVault"; + docs: ["has alpha vault"]; + type: "bool"; + }, + { + name: "liquidity"; + docs: ["initialize liquidity"]; + type: "u128"; + }, + { + name: "sqrtPrice"; + docs: [ + "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value" + ]; + type: "u128"; + }, + { + name: "activationType"; + docs: ["activation type"]; + type: "u8"; + }, + { + name: "collectFeeMode"; + docs: ["collect fee mode"]; + type: "u8"; + }, + { + name: "activationPoint"; + docs: ["activation point"]; + type: { + option: "u64"; + }; + } + ]; + }; + }, + { + name: "initializePoolParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "liquidity"; + docs: ["initialize liquidity"]; + type: "u128"; + }, + { + name: "sqrtPrice"; + docs: [ + "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value" + ]; + type: "u128"; + }, + { + name: "activationPoint"; + docs: ["activation point"]; + type: { + option: "u64"; + }; + } + ]; + }; + }, + { + name: "pool"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "poolFees"; + docs: ["Pool fee"]; + type: { + defined: { + name: "poolFeesStruct"; + }; + }; + }, + { + name: "tokenAMint"; + docs: ["token a mint"]; + type: "pubkey"; + }, + { + name: "tokenBMint"; + docs: ["token b mint"]; + type: "pubkey"; + }, + { + name: "tokenAVault"; + docs: ["token a vault"]; + type: "pubkey"; + }, + { + name: "tokenBVault"; + docs: ["token b vault"]; + type: "pubkey"; + }, + { + name: "whitelistedVault"; + docs: [ + "Whitelisted vault to be able to buy pool before activation_point" + ]; + type: "pubkey"; + }, + { + name: "partner"; + docs: ["partner"]; + type: "pubkey"; + }, + { + name: "liquidity"; + docs: ["liquidity share"]; + type: "u128"; + }, + { + name: "padding"; + docs: [ + "padding, previous reserve amount, be careful to use that field" + ]; + type: "u128"; + }, + { + name: "protocolAFee"; + docs: ["protocol a fee"]; + type: "u64"; + }, + { + name: "protocolBFee"; + docs: ["protocol b fee"]; + type: "u64"; + }, + { + name: "partnerAFee"; + docs: ["partner a fee"]; + type: "u64"; + }, + { + name: "partnerBFee"; + docs: ["partner b fee"]; + type: "u64"; + }, + { + name: "sqrtMinPrice"; + docs: ["min price"]; + type: "u128"; + }, + { + name: "sqrtMaxPrice"; + docs: ["max price"]; + type: "u128"; + }, + { + name: "sqrtPrice"; + docs: ["current price"]; + type: "u128"; + }, + { + name: "activationPoint"; + docs: ["Activation point, can be slot or timestamp"]; + type: "u64"; + }, + { + name: "activationType"; + docs: ["Activation type, 0 means by slot, 1 means by timestamp"]; + type: "u8"; + }, + { + name: "poolStatus"; + docs: ["pool status, 0: enable, 1 disable"]; + type: "u8"; + }, + { + name: "tokenAFlag"; + docs: ["token a flag"]; + type: "u8"; + }, + { + name: "tokenBFlag"; + docs: ["token b flag"]; + type: "u8"; + }, + { + name: "collectFeeMode"; + docs: [ + "0 is collect fee in both token, 1 only collect fee in token a, 2 only collect fee in token b" + ]; + type: "u8"; + }, + { + name: "poolType"; + docs: ["pool type"]; + type: "u8"; + }, + { + name: "padding0"; + docs: ["padding"]; + type: { + array: ["u8", 2]; + }; + }, + { + name: "feeAPerLiquidity"; + docs: ["cumulative"]; + type: { + array: ["u8", 32]; + }; + }, + { + name: "feeBPerLiquidity"; + docs: ["cumulative"]; + type: { + array: ["u8", 32]; + }; + }, + { + name: "permanentLockLiquidity"; + type: "u128"; + }, + { + name: "metrics"; + docs: ["metrics"]; + type: { + defined: { + name: "poolMetrics"; + }; + }; + }, + { + name: "creator"; + docs: ["pool creator"]; + type: "pubkey"; + }, + { + name: "padding1"; + docs: ["Padding for further use"]; + type: { + array: ["u64", 6]; + }; + }, + { + name: "rewardInfos"; + docs: ["Farming reward information"]; + type: { + array: [ + { + defined: { + name: "rewardInfo"; + }; + }, + 2 + ]; + }; + } + ]; + }; + }, + { + name: "poolFeeParameters"; + docs: ["Information regarding fee charges"]; + type: { + kind: "struct"; + fields: [ + { + name: "baseFee"; + docs: ["Base fee"]; + type: { + defined: { + name: "baseFeeParameters"; + }; + }; + }, + { + name: "padding"; + docs: ["padding"]; + type: { + array: ["u8", 3]; + }; + }, + { + name: "dynamicFee"; + docs: ["dynamic fee"]; + type: { + option: { + defined: { + name: "dynamicFeeParameters"; + }; + }; + }; + } + ]; + }; + }, + { + name: "poolFeesConfig"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "baseFee"; + type: { + defined: { + name: "baseFeeConfig"; + }; + }; + }, + { + name: "dynamicFee"; + type: { + defined: { + name: "dynamicFeeConfig"; + }; + }; + }, + { + name: "protocolFeePercent"; + type: "u8"; + }, + { + name: "partnerFeePercent"; + type: "u8"; + }, + { + name: "referralFeePercent"; + type: "u8"; + }, + { + name: "padding0"; + type: { + array: ["u8", 5]; + }; + }, + { + name: "padding1"; + type: { + array: ["u64", 5]; + }; + } + ]; + }; + }, + { + name: "poolFeesStruct"; + docs: [ + "Information regarding fee charges", + "trading_fee = amount * trade_fee_numerator / denominator", + "protocol_fee = trading_fee * protocol_fee_percentage / 100", + "referral_fee = protocol_fee * referral_percentage / 100", + "partner_fee = (protocol_fee - referral_fee) * partner_fee_percentage / denominator" + ]; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "baseFee"; + docs: [ + "Trade fees are extra token amounts that are held inside the token", + "accounts during a trade, making the value of liquidity tokens rise.", + "Trade fee numerator" + ]; + type: { + defined: { + name: "baseFeeStruct"; + }; + }; + }, + { + name: "protocolFeePercent"; + docs: [ + "Protocol trading fees are extra token amounts that are held inside the token", + "accounts during a trade, with the equivalent in pool tokens minted to", + "the protocol of the program.", + "Protocol trade fee numerator" + ]; + type: "u8"; + }, + { + name: "partnerFeePercent"; + docs: ["partner fee"]; + type: "u8"; + }, + { + name: "referralFeePercent"; + docs: ["referral fee"]; + type: "u8"; + }, + { + name: "padding0"; + docs: ["padding"]; + type: { + array: ["u8", 5]; + }; + }, + { + name: "dynamicFee"; + docs: ["dynamic fee"]; + type: { + defined: { + name: "dynamicFeeStruct"; + }; + }; + }, + { + name: "padding1"; + docs: ["padding"]; + type: { + array: ["u64", 2]; + }; + } + ]; + }; + }, + { + name: "poolMetrics"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "totalLpAFee"; + type: "u128"; + }, + { + name: "totalLpBFee"; + type: "u128"; + }, + { + name: "totalProtocolAFee"; + type: "u64"; + }, + { + name: "totalProtocolBFee"; + type: "u64"; + }, + { + name: "totalPartnerAFee"; + type: "u64"; + }, + { + name: "totalPartnerBFee"; + type: "u64"; + }, + { + name: "totalPosition"; + type: "u64"; + }, + { + name: "padding"; + type: "u64"; + } + ]; + }; + }, + { + name: "position"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "nftMint"; + docs: ["nft mint"]; + type: "pubkey"; + }, + { + name: "feeAPerTokenCheckpoint"; + docs: ["fee a checkpoint"]; + type: { + array: ["u8", 32]; + }; + }, + { + name: "feeBPerTokenCheckpoint"; + docs: ["fee b checkpoint"]; + type: { + array: ["u8", 32]; + }; + }, + { + name: "feeAPending"; + docs: ["fee a pending"]; + type: "u64"; + }, + { + name: "feeBPending"; + docs: ["fee b pending"]; + type: "u64"; + }, + { + name: "unlockedLiquidity"; + docs: ["unlock liquidity"]; + type: "u128"; + }, + { + name: "vestedLiquidity"; + docs: ["vesting liquidity"]; + type: "u128"; + }, + { + name: "permanentLockedLiquidity"; + docs: ["permanent locked liquidity"]; + type: "u128"; + }, + { + name: "metrics"; + docs: ["metrics"]; + type: { + defined: { + name: "positionMetrics"; + }; + }; + }, + { + name: "rewardInfos"; + docs: ["Farming reward information"]; + type: { + array: [ + { + defined: { + name: "userRewardInfo"; + }; + }, + 2 + ]; + }; + }, + { + name: "padding"; + docs: ["padding for future usage"]; + type: { + array: ["u128", 6]; + }; + } + ]; + }; + }, + { + name: "positionMetrics"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "totalClaimedAFee"; + type: "u64"; + }, + { + name: "totalClaimedBFee"; + type: "u64"; + } + ]; + }; + }, + { + name: "removeLiquidityParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "liquidityDelta"; + docs: ["delta liquidity"]; + type: "u128"; + }, + { + name: "tokenAAmountThreshold"; + docs: ["minimum token a amount"]; + type: "u64"; + }, + { + name: "tokenBAmountThreshold"; + docs: ["minimum token b amount"]; + type: "u64"; + } + ]; + }; + }, + { + name: "rewardInfo"; + docs: ["Stores the state relevant for tracking liquidity mining rewards"]; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "initialized"; + docs: ["Indicates if the reward has been initialized"]; + type: "u8"; + }, + { + name: "rewardTokenFlag"; + docs: ["reward token flag"]; + type: "u8"; + }, + { + name: "padding0"; + docs: ["padding"]; + type: { + array: ["u8", 6]; + }; + }, + { + name: "padding1"; + docs: ["Padding to ensure `reward_rate: u128` is 16-byte aligned"]; + type: { + array: ["u8", 8]; + }; + }, + { + name: "mint"; + docs: ["Reward token mint."]; + type: "pubkey"; + }, + { + name: "vault"; + docs: ["Reward vault token account."]; + type: "pubkey"; + }, + { + name: "funder"; + docs: ["Authority account that allows to fund rewards"]; + type: "pubkey"; + }, + { + name: "rewardDuration"; + docs: ["reward duration"]; + type: "u64"; + }, + { + name: "rewardDurationEnd"; + docs: ["reward duration end"]; + type: "u64"; + }, + { + name: "rewardRate"; + docs: ["reward rate"]; + type: "u128"; + }, + { + name: "rewardPerTokenStored"; + docs: ["Reward per token stored"]; + type: { + array: ["u8", 32]; + }; + }, + { + name: "lastUpdateTime"; + docs: ["The last time reward states were updated."]; + type: "u64"; + }, + { + name: "cumulativeSecondsWithEmptyLiquidityReward"; + docs: [ + "Accumulated seconds when the farm distributed rewards but the bin was empty.", + "These rewards will be carried over to the next reward time window." + ]; + type: "u64"; + } + ]; + }; + }, + { + name: "splitAmountInfo"; + type: { + kind: "struct"; + fields: [ + { + name: "permanentLockedLiquidity"; + type: "u128"; + }, + { + name: "unlockedLiquidity"; + type: "u128"; + }, + { + name: "feeA"; + type: "u64"; + }, + { + name: "feeB"; + type: "u64"; + }, + { + name: "reward0"; + type: "u64"; + }, + { + name: "reward1"; + type: "u64"; + } + ]; + }; + }, + { + name: "splitPositionInfo"; + type: { + kind: "struct"; + fields: [ + { + name: "liquidity"; + type: "u128"; + }, + { + name: "feeA"; + type: "u64"; + }, + { + name: "feeB"; + type: "u64"; + }, + { + name: "reward0"; + type: "u64"; + }, + { + name: "reward1"; + type: "u64"; + } + ]; + }; + }, + { + name: "splitPositionParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "unlockedLiquidityPercentage"; + docs: [ + "Percentage of unlocked liquidity to split to the second position" + ]; + type: "u8"; + }, + { + name: "permanentLockedLiquidityPercentage"; + docs: [ + "Percentage of permanent locked liquidity to split to the second position" + ]; + type: "u8"; + }, + { + name: "feeAPercentage"; + docs: [ + "Percentage of fee A pending to split to the second position" + ]; + type: "u8"; + }, + { + name: "feeBPercentage"; + docs: [ + "Percentage of fee B pending to split to the second position" + ]; + type: "u8"; + }, + { + name: "reward0Percentage"; + docs: [ + "Percentage of reward 0 pending to split to the second position" + ]; + type: "u8"; + }, + { + name: "reward1Percentage"; + docs: [ + "Percentage of reward 1 pending to split to the second position" + ]; + type: "u8"; + }, + { + name: "padding"; + docs: ["padding for future"]; + type: { + array: ["u8", 16]; + }; + } + ]; + }; + }, + { + name: "staticConfigParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "poolFees"; + type: { + defined: { + name: "poolFeeParameters"; + }; + }; + }, + { + name: "sqrtMinPrice"; + type: "u128"; + }, + { + name: "sqrtMaxPrice"; + type: "u128"; + }, + { + name: "vaultConfigKey"; + type: "pubkey"; + }, + { + name: "poolCreatorAuthority"; + type: "pubkey"; + }, + { + name: "activationType"; + type: "u8"; + }, + { + name: "collectFeeMode"; + type: "u8"; + } + ]; + }; + }, + { + name: "swapParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "amountIn"; + type: "u64"; + }, + { + name: "minimumAmountOut"; + type: "u64"; + } + ]; + }; + }, + { + 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: "tokenBadge"; + docs: ["Parameter that set by the protocol"]; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "tokenMint"; + docs: ["token mint"]; + type: "pubkey"; + }, + { + name: "padding"; + docs: ["Reserve"]; + type: { + array: ["u8", 128]; + }; + } + ]; + }; + }, + { + name: "userRewardInfo"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "rewardPerTokenCheckpoint"; + docs: ["The latest update reward checkpoint"]; + type: { + array: ["u8", 32]; + }; + }, + { + name: "rewardPendings"; + docs: ["Current pending rewards"]; + type: "u64"; + }, + { + name: "totalClaimedRewards"; + docs: ["Total claimed rewards"]; + type: "u64"; + } + ]; + }; + }, + { + name: "vesting"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "position"; + type: "pubkey"; + }, + { + name: "cliffPoint"; + type: "u64"; + }, + { + name: "periodFrequency"; + type: "u64"; + }, + { + name: "cliffUnlockLiquidity"; + type: "u128"; + }, + { + name: "liquidityPerPeriod"; + type: "u128"; + }, + { + name: "totalReleasedLiquidity"; + type: "u128"; + }, + { + name: "numberOfPeriod"; + type: "u16"; + }, + { + name: "padding"; + type: { + array: ["u8", 14]; + }; + }, + { + name: "padding2"; + type: { + array: ["u128", 4]; + }; + } + ]; + }; + }, + { + name: "vestingParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "cliffPoint"; + type: { + option: "u64"; + }; + }, + { + name: "periodFrequency"; + type: "u64"; + }, + { + name: "cliffUnlockLiquidity"; + type: "u128"; + }, + { + name: "liquidityPerPeriod"; + type: "u128"; + }, + { + name: "numberOfPeriod"; + type: "u16"; + } + ]; + }; + } + ]; +}; diff --git a/tests/common/idl/dynamic_bonding_curve.ts b/tests/common/idl/dynamic_bonding_curve.ts new file mode 100644 index 0000000..873e43c --- /dev/null +++ b/tests/common/idl/dynamic_bonding_curve.ts @@ -0,0 +1,5248 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/dynamic_bonding_curve.json`. + */ +export type DynamicBondingCurve = { + address: "dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN"; + metadata: { + name: "dynamicBondingCurve"; + version: "0.1.6"; + spec: "0.1.0"; + description: "Created with Anchor"; + }; + instructions: [ + { + name: "claimCreatorTradingFee"; + discriminator: [82, 220, 250, 189, 3, 85, 107, 45]; + accounts: [ + { + name: "poolAuthority"; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "pool"; + writable: true; + }, + { + name: "tokenAAccount"; + docs: ["The treasury token a account"]; + writable: true; + }, + { + name: "tokenBAccount"; + docs: ["The treasury token b account"]; + writable: true; + }, + { + name: "baseVault"; + docs: ["The vault token account for input token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "quoteVault"; + docs: ["The vault token account for output token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "baseMint"; + docs: ["The mint of token a"]; + relations: ["pool"]; + }, + { + name: "quoteMint"; + docs: ["The mint of token b"]; + }, + { + name: "creator"; + signer: true; + relations: ["pool"]; + }, + { + name: "tokenBaseProgram"; + docs: ["Token a program"]; + }, + { + name: "tokenQuoteProgram"; + docs: ["Token b program"]; + }, + { + 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: "maxBaseAmount"; + type: "u64"; + }, + { + name: "maxQuoteAmount"; + type: "u64"; + } + ]; + }, + { + name: "claimProtocolFee"; + discriminator: [165, 228, 133, 48, 99, 249, 255, 33]; + accounts: [ + { + name: "poolAuthority"; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "config"; + relations: ["pool"]; + }, + { + name: "pool"; + writable: true; + }, + { + name: "baseVault"; + docs: ["The vault token account for input token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "quoteVault"; + docs: ["The vault token account for output token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "baseMint"; + docs: ["The mint of token a"]; + relations: ["pool"]; + }, + { + name: "quoteMint"; + docs: ["The mint of token b"]; + relations: ["config"]; + }, + { + name: "tokenBaseAccount"; + 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: "tokenBaseProgram"; + }, + { + kind: "account"; + path: "baseMint"; + } + ]; + 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: "tokenQuoteAccount"; + 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: "tokenQuoteProgram"; + }, + { + kind: "account"; + path: "quoteMint"; + } + ]; + 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"; + docs: ["Claim fee operator"]; + }, + { + name: "operator"; + docs: ["Operator"]; + signer: true; + relations: ["claimFeeOperator"]; + }, + { + name: "tokenBaseProgram"; + docs: ["Token a program"]; + }, + { + name: "tokenQuoteProgram"; + docs: ["Token b program"]; + }, + { + 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: "claimTradingFee"; + discriminator: [8, 236, 89, 49, 152, 125, 177, 81]; + accounts: [ + { + name: "poolAuthority"; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "config"; + relations: ["pool"]; + }, + { + name: "pool"; + writable: true; + }, + { + name: "tokenAAccount"; + docs: ["The treasury token a account"]; + writable: true; + }, + { + name: "tokenBAccount"; + docs: ["The treasury token b account"]; + writable: true; + }, + { + name: "baseVault"; + docs: ["The vault token account for input token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "quoteVault"; + docs: ["The vault token account for output token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "baseMint"; + docs: ["The mint of token a"]; + relations: ["pool"]; + }, + { + name: "quoteMint"; + docs: ["The mint of token b"]; + relations: ["config"]; + }, + { + name: "feeClaimer"; + signer: true; + relations: ["config"]; + }, + { + name: "tokenBaseProgram"; + docs: ["Token a program"]; + }, + { + name: "tokenQuoteProgram"; + docs: ["Token b program"]; + }, + { + 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: "maxAmountA"; + type: "u64"; + }, + { + name: "maxAmountB"; + type: "u64"; + } + ]; + }, + { + name: "closeClaimFeeOperator"; + discriminator: [38, 134, 82, 216, 95, 124, 17, 99]; + accounts: [ + { + name: "claimFeeOperator"; + writable: true; + }, + { + name: "rentReceiver"; + writable: true; + }, + { + name: "admin"; + 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: "createClaimFeeOperator"; + docs: ["ADMIN FUNCTIONS_ ///"]; + discriminator: [169, 62, 207, 107, 58, 187, 162, 109]; + accounts: [ + { + name: "claimFeeOperator"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [99, 102, 95, 111, 112, 101, 114, 97, 116, 111, 114]; + }, + { + kind: "account"; + path: "operator"; + } + ]; + }; + }, + { + name: "operator"; + }, + { + name: "admin"; + writable: true; + signer: true; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: []; + }, + { + name: "createConfig"; + discriminator: [201, 207, 243, 114, 75, 111, 47, 189]; + accounts: [ + { + name: "config"; + writable: true; + signer: true; + }, + { + name: "feeClaimer"; + }, + { + name: "leftoverReceiver"; + }, + { + name: "quoteMint"; + docs: ["quote mint"]; + }, + { + name: "payer"; + writable: true; + signer: true; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: [ + { + name: "configParameters"; + type: { + defined: { + name: "configParameters"; + }; + }; + } + ]; + }, + { + name: "createLocker"; + docs: ["PERMISSIONLESS FUNCTIONS ///", "create locker"]; + discriminator: [167, 90, 137, 154, 75, 47, 17, 84]; + accounts: [ + { + name: "virtualPool"; + docs: ["Virtual pool"]; + writable: true; + }, + { + name: "config"; + docs: ["config"]; + relations: ["virtualPool"]; + }, + { + name: "poolAuthority"; + writable: true; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "baseVault"; + writable: true; + relations: ["virtualPool"]; + }, + { + name: "baseMint"; + writable: true; + relations: ["virtualPool"]; + }, + { + name: "base"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [98, 97, 115, 101, 95, 108, 111, 99, 107, 101, 114]; + }, + { + kind: "account"; + path: "virtualPool"; + } + ]; + }; + }, + { + name: "creator"; + relations: ["virtualPool"]; + }, + { + name: "escrow"; + writable: true; + }, + { + name: "escrowToken"; + writable: true; + }, + { + name: "payer"; + writable: true; + signer: true; + }, + { + name: "tokenProgram"; + }, + { + name: "lockerProgram"; + address: "LocpQgucEQHbqNABEYvBvwoxCPsSbG91A1QaQhQQqjn"; + }, + { + name: "lockerEventAuthority"; + }, + { + name: "systemProgram"; + docs: ["System program."]; + address: "11111111111111111111111111111111"; + } + ]; + args: []; + }, + { + name: "createPartnerMetadata"; + docs: ["PARTNER FUNCTIONS ////"]; + discriminator: [192, 168, 234, 191, 188, 226, 227, 255]; + accounts: [ + { + name: "partnerMetadata"; + docs: ["Partner metadata"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 112, + 97, + 114, + 116, + 110, + 101, + 114, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ]; + }, + { + kind: "account"; + path: "feeClaimer"; + } + ]; + }; + }, + { + name: "payer"; + docs: ["Payer of the partner metadata."]; + writable: true; + signer: true; + }, + { + name: "feeClaimer"; + docs: ["Fee claimer for partner"]; + signer: true; + }, + { + name: "systemProgram"; + docs: ["System program."]; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: [ + { + name: "metadata"; + type: { + defined: { + name: "createPartnerMetadataParameters"; + }; + }; + } + ]; + }, + { + name: "createVirtualPoolMetadata"; + discriminator: [45, 97, 187, 103, 254, 109, 124, 134]; + accounts: [ + { + name: "virtualPool"; + writable: true; + }, + { + name: "virtualPoolMetadata"; + docs: ["Virtual pool metadata"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 118, + 105, + 114, + 116, + 117, + 97, + 108, + 95, + 112, + 111, + 111, + 108, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ]; + }, + { + kind: "account"; + path: "virtualPool"; + } + ]; + }; + }, + { + name: "creator"; + signer: true; + relations: ["virtualPool"]; + }, + { + name: "payer"; + docs: ["Payer of the virtual pool metadata."]; + writable: true; + signer: true; + }, + { + name: "systemProgram"; + docs: ["System program."]; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: [ + { + name: "metadata"; + type: { + defined: { + name: "createVirtualPoolMetadataParameters"; + }; + }; + } + ]; + }, + { + name: "creatorWithdrawSurplus"; + discriminator: [165, 3, 137, 7, 28, 134, 76, 80]; + accounts: [ + { + name: "poolAuthority"; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "config"; + relations: ["virtualPool"]; + }, + { + name: "virtualPool"; + writable: true; + }, + { + name: "tokenQuoteAccount"; + docs: ["The receiver token account"]; + writable: true; + }, + { + name: "quoteVault"; + docs: ["The vault token account for output token"]; + writable: true; + relations: ["virtualPool"]; + }, + { + name: "quoteMint"; + docs: ["The mint of quote token"]; + relations: ["config"]; + }, + { + name: "creator"; + signer: true; + relations: ["virtualPool"]; + }, + { + name: "tokenQuoteProgram"; + docs: ["Token b program"]; + }, + { + 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: "initializeVirtualPoolWithSplToken"; + docs: ["POOL CREATOR FUNCTIONS ////"]; + discriminator: [140, 85, 215, 176, 102, 54, 104, 79]; + accounts: [ + { + name: "config"; + docs: ["Which config the pool belongs to."]; + }, + { + name: "poolAuthority"; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "creator"; + signer: true; + }, + { + name: "baseMint"; + writable: true; + signer: true; + }, + { + name: "quoteMint"; + relations: ["config"]; + }, + { + name: "pool"; + docs: ["Initialize an account to store the pool state"]; + writable: true; + }, + { + name: "baseVault"; + 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]; + }, + { + kind: "account"; + path: "baseMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "quoteVault"; + 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]; + }, + { + kind: "account"; + path: "quoteMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "mintMetadata"; + writable: true; + }, + { + name: "metadataProgram"; + address: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"; + }, + { + name: "payer"; + docs: ["Address paying to create the pool. Can be anyone"]; + writable: true; + signer: true; + }, + { + name: "tokenQuoteProgram"; + docs: ["Program to create mint account and mint tokens"]; + }, + { + name: "tokenProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: [ + { + name: "params"; + type: { + defined: { + name: "initializePoolParameters"; + }; + }; + } + ]; + }, + { + name: "initializeVirtualPoolWithToken2022"; + discriminator: [169, 118, 51, 78, 145, 110, 220, 155]; + accounts: [ + { + name: "config"; + docs: ["Which config the pool belongs to."]; + }, + { + name: "poolAuthority"; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "creator"; + signer: true; + }, + { + name: "baseMint"; + docs: ["Unique token mint address, initialize in contract"]; + writable: true; + signer: true; + }, + { + name: "quoteMint"; + relations: ["config"]; + }, + { + name: "pool"; + docs: ["Initialize an account to store the pool state"]; + writable: true; + }, + { + name: "baseVault"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116]; + }, + { + kind: "account"; + path: "baseMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "quoteVault"; + docs: ["Token quote vault for the pool"]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116]; + }, + { + kind: "account"; + path: "quoteMint"; + }, + { + kind: "account"; + path: "pool"; + } + ]; + }; + }, + { + name: "payer"; + docs: ["Address paying to create the pool. Can be anyone"]; + writable: true; + signer: true; + }, + { + name: "tokenQuoteProgram"; + docs: ["Program to create mint account and mint tokens"]; + }, + { + name: "tokenProgram"; + docs: ["token program for base mint"]; + address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: [ + { + name: "params"; + type: { + defined: { + name: "initializePoolParameters"; + }; + }; + } + ]; + }, + { + name: "migrateMeteoraDamm"; + discriminator: [27, 1, 48, 22, 180, 63, 118, 217]; + accounts: [ + { + name: "virtualPool"; + docs: ["virtual pool"]; + writable: true; + relations: ["migrationMetadata"]; + }, + { + name: "migrationMetadata"; + writable: true; + }, + { + name: "config"; + relations: ["virtualPool"]; + }, + { + name: "poolAuthority"; + writable: true; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "pool"; + writable: true; + }, + { + name: "dammConfig"; + docs: ["pool config"]; + }, + { + name: "lpMint"; + writable: true; + }, + { + name: "tokenAMint"; + writable: true; + }, + { + name: "tokenBMint"; + }, + { + name: "aVault"; + writable: true; + }, + { + name: "bVault"; + writable: true; + }, + { + name: "aTokenVault"; + writable: true; + }, + { + name: "bTokenVault"; + writable: true; + }, + { + name: "aVaultLpMint"; + writable: true; + }, + { + name: "bVaultLpMint"; + writable: true; + }, + { + name: "aVaultLp"; + writable: true; + }, + { + name: "bVaultLp"; + writable: true; + }, + { + name: "baseVault"; + writable: true; + relations: ["virtualPool"]; + }, + { + name: "quoteVault"; + writable: true; + relations: ["virtualPool"]; + }, + { + name: "virtualPoolLp"; + writable: true; + }, + { + name: "protocolTokenAFee"; + writable: true; + }, + { + name: "protocolTokenBFee"; + writable: true; + }, + { + name: "payer"; + writable: true; + signer: true; + }, + { + name: "rent"; + }, + { + name: "mintMetadata"; + writable: true; + }, + { + name: "metadataProgram"; + }, + { + name: "ammProgram"; + address: "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB"; + }, + { + name: "vaultProgram"; + }, + { + name: "tokenProgram"; + docs: ["tokenProgram"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "associatedTokenProgram"; + }, + { + name: "systemProgram"; + docs: ["System program."]; + address: "11111111111111111111111111111111"; + } + ]; + args: []; + }, + { + name: "migrateMeteoraDammClaimLpToken"; + discriminator: [139, 133, 2, 30, 91, 145, 127, 154]; + accounts: [ + { + name: "virtualPool"; + relations: ["migrationMetadata"]; + }, + { + name: "migrationMetadata"; + docs: ["migration metadata"]; + writable: true; + }, + { + name: "poolAuthority"; + writable: true; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "lpMint"; + relations: ["migrationMetadata"]; + }, + { + name: "sourceToken"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "poolAuthority"; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ]; + }, + { + kind: "account"; + path: "migrationMetadata"; + } + ]; + 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: "destinationToken"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "owner"; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ]; + }, + { + kind: "account"; + path: "migrationMetadata"; + } + ]; + 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: "owner"; + }, + { + name: "sender"; + signer: true; + }, + { + name: "tokenProgram"; + docs: ["tokenProgram"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + } + ]; + args: []; + }, + { + name: "migrateMeteoraDammLockLpToken"; + discriminator: [177, 55, 238, 157, 251, 88, 165, 42]; + accounts: [ + { + name: "virtualPool"; + relations: ["migrationMetadata"]; + }, + { + name: "migrationMetadata"; + docs: ["migrationMetadata"]; + writable: true; + }, + { + name: "poolAuthority"; + writable: true; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "pool"; + writable: true; + relations: ["lockEscrow"]; + }, + { + name: "lpMint"; + relations: ["migrationMetadata"]; + }, + { + name: "lockEscrow"; + writable: true; + }, + { + name: "owner"; + relations: ["lockEscrow"]; + }, + { + name: "sourceTokens"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "poolAuthority"; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ]; + }, + { + kind: "account"; + path: "migrationMetadata"; + } + ]; + 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: "escrowVault"; + writable: true; + }, + { + name: "ammProgram"; + address: "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB"; + }, + { + name: "aVault"; + }, + { + name: "bVault"; + }, + { + name: "aVaultLp"; + }, + { + name: "bVaultLp"; + }, + { + name: "aVaultLpMint"; + }, + { + name: "bVaultLpMint"; + }, + { + name: "tokenProgram"; + docs: ["tokenProgram"]; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + } + ]; + args: []; + }, + { + name: "migrationDammV2"; + discriminator: [156, 169, 230, 103, 53, 228, 80, 64]; + accounts: [ + { + name: "virtualPool"; + docs: ["virtual pool"]; + writable: true; + relations: ["migrationMetadata"]; + }, + { + name: "migrationMetadata"; + docs: ["migration metadata"]; + }, + { + name: "config"; + docs: ["virtual pool config key"]; + relations: ["virtualPool"]; + }, + { + name: "poolAuthority"; + writable: true; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "pool"; + writable: true; + }, + { + name: "firstPositionNftMint"; + writable: true; + }, + { + name: "firstPositionNftAccount"; + writable: true; + }, + { + name: "firstPosition"; + writable: true; + }, + { + name: "secondPositionNftMint"; + writable: true; + optional: true; + }, + { + name: "secondPositionNftAccount"; + writable: true; + optional: true; + }, + { + name: "secondPosition"; + writable: true; + optional: true; + }, + { + name: "dammPoolAuthority"; + }, + { + name: "ammProgram"; + address: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"; + }, + { + name: "baseMint"; + writable: true; + }, + { + name: "quoteMint"; + writable: true; + }, + { + name: "tokenAVault"; + writable: true; + }, + { + name: "tokenBVault"; + writable: true; + }, + { + name: "baseVault"; + writable: true; + relations: ["virtualPool"]; + }, + { + name: "quoteVault"; + writable: true; + relations: ["virtualPool"]; + }, + { + name: "payer"; + writable: true; + signer: true; + }, + { + name: "tokenBaseProgram"; + }, + { + name: "tokenQuoteProgram"; + }, + { + name: "token2022Program"; + }, + { + name: "dammEventAuthority"; + }, + { + name: "systemProgram"; + docs: ["System program."]; + address: "11111111111111111111111111111111"; + } + ]; + args: []; + }, + { + name: "migrationDammV2CreateMetadata"; + discriminator: [109, 189, 19, 36, 195, 183, 222, 82]; + accounts: [ + { + name: "virtualPool"; + }, + { + name: "config"; + relations: ["virtualPool"]; + }, + { + name: "migrationMetadata"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [100, 97, 109, 109, 95, 118, 50]; + }, + { + kind: "account"; + path: "virtualPool"; + } + ]; + }; + }, + { + name: "payer"; + writable: true; + signer: true; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: []; + }, + { + name: "migrationMeteoraDammCreateMetadata"; + docs: ["migrate damm v1"]; + discriminator: [47, 94, 126, 115, 221, 226, 194, 133]; + accounts: [ + { + name: "virtualPool"; + }, + { + name: "config"; + relations: ["virtualPool"]; + }, + { + name: "migrationMetadata"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [109, 101, 116, 101, 111, 114, 97]; + }, + { + kind: "account"; + path: "virtualPool"; + } + ]; + }; + }, + { + name: "payer"; + writable: true; + signer: true; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: []; + }, + { + name: "partnerWithdrawSurplus"; + discriminator: [168, 173, 72, 100, 201, 98, 38, 92]; + accounts: [ + { + name: "poolAuthority"; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "config"; + relations: ["virtualPool"]; + }, + { + name: "virtualPool"; + writable: true; + }, + { + name: "tokenQuoteAccount"; + docs: ["The receiver token account"]; + writable: true; + }, + { + name: "quoteVault"; + docs: ["The vault token account for output token"]; + writable: true; + relations: ["virtualPool"]; + }, + { + name: "quoteMint"; + docs: ["The mint of quote token"]; + relations: ["config"]; + }, + { + name: "feeClaimer"; + signer: true; + relations: ["config"]; + }, + { + name: "tokenQuoteProgram"; + docs: ["Token b program"]; + }, + { + 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: "protocolWithdrawSurplus"; + discriminator: [54, 136, 225, 138, 172, 182, 214, 167]; + accounts: [ + { + name: "poolAuthority"; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "config"; + relations: ["virtualPool"]; + }, + { + name: "virtualPool"; + writable: true; + }, + { + name: "tokenQuoteAccount"; + docs: ["The treasury quote token 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: "tokenQuoteProgram"; + }, + { + kind: "account"; + path: "quoteMint"; + } + ]; + 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: "quoteVault"; + docs: ["The vault token account for quote token"]; + writable: true; + relations: ["virtualPool"]; + }, + { + name: "quoteMint"; + docs: ["The mint of token"]; + relations: ["config"]; + }, + { + name: "tokenQuoteProgram"; + docs: ["Token b program"]; + }, + { + 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: "swap"; + docs: ["TRADING BOTS FUNCTIONS ////"]; + discriminator: [248, 198, 158, 145, 225, 117, 135, 200]; + accounts: [ + { + name: "poolAuthority"; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "config"; + docs: ["config key"]; + relations: ["pool"]; + }, + { + name: "pool"; + docs: ["Pool account"]; + writable: true; + }, + { + name: "inputTokenAccount"; + docs: ["The user token account for input token"]; + writable: true; + }, + { + name: "outputTokenAccount"; + docs: ["The user token account for output token"]; + writable: true; + }, + { + name: "baseVault"; + docs: ["The vault token account for base token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "quoteVault"; + docs: ["The vault token account for quote token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "baseMint"; + docs: ["The mint of base token"]; + }, + { + name: "quoteMint"; + docs: ["The mint of quote token"]; + }, + { + name: "payer"; + docs: ["The user performing the swap"]; + signer: true; + }, + { + name: "tokenBaseProgram"; + docs: ["Token base program"]; + }, + { + name: "tokenQuoteProgram"; + docs: ["Token quote program"]; + }, + { + name: "referralTokenAccount"; + docs: ["referral token account"]; + writable: true; + optional: 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: "swapParameters"; + }; + }; + } + ]; + }, + { + name: "swap2"; + discriminator: [65, 75, 63, 76, 235, 91, 91, 136]; + accounts: [ + { + name: "poolAuthority"; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "config"; + docs: ["config key"]; + relations: ["pool"]; + }, + { + name: "pool"; + docs: ["Pool account"]; + writable: true; + }, + { + name: "inputTokenAccount"; + docs: ["The user token account for input token"]; + writable: true; + }, + { + name: "outputTokenAccount"; + docs: ["The user token account for output token"]; + writable: true; + }, + { + name: "baseVault"; + docs: ["The vault token account for base token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "quoteVault"; + docs: ["The vault token account for quote token"]; + writable: true; + relations: ["pool"]; + }, + { + name: "baseMint"; + docs: ["The mint of base token"]; + }, + { + name: "quoteMint"; + docs: ["The mint of quote token"]; + }, + { + name: "payer"; + docs: ["The user performing the swap"]; + signer: true; + }, + { + name: "tokenBaseProgram"; + docs: ["Token base program"]; + }, + { + name: "tokenQuoteProgram"; + docs: ["Token quote program"]; + }, + { + name: "referralTokenAccount"; + docs: ["referral token account"]; + writable: true; + optional: 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: "swapParameters2"; + }; + }; + } + ]; + }, + { + name: "transferPoolCreator"; + discriminator: [20, 7, 169, 33, 58, 147, 166, 33]; + accounts: [ + { + name: "virtualPool"; + writable: true; + }, + { + name: "config"; + relations: ["virtualPool"]; + }, + { + name: "creator"; + signer: true; + relations: ["virtualPool"]; + }, + { + name: "newCreator"; + }, + { + 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: "withdrawLeftover"; + discriminator: [20, 198, 202, 237, 235, 243, 183, 66]; + accounts: [ + { + name: "poolAuthority"; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "config"; + relations: ["virtualPool"]; + }, + { + name: "virtualPool"; + writable: true; + }, + { + name: "tokenBaseAccount"; + docs: ["The receiver token account, withdraw to ATA"]; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "leftoverReceiver"; + }, + { + kind: "account"; + path: "tokenBaseProgram"; + }, + { + kind: "account"; + path: "baseMint"; + } + ]; + 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: "baseVault"; + docs: ["The vault token account for output token"]; + writable: true; + relations: ["virtualPool"]; + }, + { + name: "baseMint"; + docs: ["The mint of quote token"]; + relations: ["virtualPool"]; + }, + { + name: "leftoverReceiver"; + relations: ["config"]; + }, + { + name: "tokenBaseProgram"; + docs: ["Token base program"]; + }, + { + 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: "withdrawMigrationFee"; + docs: ["BOTH partner and creator FUNCTIONS ///"]; + discriminator: [237, 142, 45, 23, 129, 6, 222, 162]; + accounts: [ + { + name: "poolAuthority"; + address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"; + }, + { + name: "config"; + relations: ["virtualPool"]; + }, + { + name: "virtualPool"; + writable: true; + }, + { + name: "tokenQuoteAccount"; + docs: ["The receiver token account"]; + writable: true; + }, + { + name: "quoteVault"; + docs: ["The vault token account for output token"]; + writable: true; + relations: ["virtualPool"]; + }, + { + name: "quoteMint"; + docs: ["The mint of quote token"]; + relations: ["config"]; + }, + { + name: "sender"; + signer: true; + }, + { + name: "tokenQuoteProgram"; + docs: ["Token b program"]; + }, + { + 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: "flag"; + 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: "lockEscrow"; + discriminator: [190, 106, 121, 6, 200, 182, 21, 75]; + }, + { + name: "meteoraDammMigrationMetadata"; + discriminator: [17, 155, 141, 215, 207, 4, 133, 156]; + }, + { + name: "meteoraDammV2Metadata"; + discriminator: [104, 221, 219, 203, 10, 142, 250, 163]; + }, + { + name: "partnerMetadata"; + discriminator: [68, 68, 130, 19, 16, 209, 98, 156]; + }, + { + name: "poolConfig"; + discriminator: [26, 108, 14, 123, 116, 230, 129, 43]; + }, + { + name: "virtualPool"; + discriminator: [213, 224, 5, 209, 98, 69, 119, 92]; + }, + { + name: "virtualPoolMetadata"; + discriminator: [217, 37, 82, 250, 43, 47, 228, 254]; + } + ]; + events: [ + { + name: "evtClaimCreatorTradingFee"; + discriminator: [154, 228, 215, 202, 133, 155, 214, 138]; + }, + { + name: "evtClaimProtocolFee"; + discriminator: [186, 244, 75, 251, 188, 13, 25, 33]; + }, + { + name: "evtClaimTradingFee"; + discriminator: [26, 83, 117, 240, 92, 202, 112, 254]; + }, + { + name: "evtCloseClaimFeeOperator"; + discriminator: [111, 39, 37, 55, 110, 216, 194, 23]; + }, + { + name: "evtCreateClaimFeeOperator"; + discriminator: [21, 6, 153, 120, 68, 116, 28, 177]; + }, + { + name: "evtCreateConfig"; + discriminator: [131, 207, 180, 174, 180, 73, 165, 54]; + }, + { + name: "evtCreateConfigV2"; + discriminator: [163, 74, 66, 187, 119, 195, 26, 144]; + }, + { + name: "evtCreateDammV2MigrationMetadata"; + discriminator: [103, 111, 132, 168, 140, 253, 150, 114]; + }, + { + name: "evtCreateMeteoraMigrationMetadata"; + discriminator: [99, 167, 133, 63, 214, 143, 175, 139]; + }, + { + name: "evtCreatorWithdrawSurplus"; + discriminator: [152, 73, 21, 15, 66, 87, 53, 157]; + }, + { + name: "evtCurveComplete"; + discriminator: [229, 231, 86, 84, 156, 134, 75, 24]; + }, + { + name: "evtInitializePool"; + discriminator: [228, 50, 246, 85, 203, 66, 134, 37]; + }, + { + name: "evtPartnerMetadata"; + discriminator: [200, 127, 6, 55, 13, 32, 8, 150]; + }, + { + name: "evtPartnerWithdrawMigrationFee"; + discriminator: [181, 105, 127, 67, 8, 187, 120, 57]; + }, + { + name: "evtPartnerWithdrawSurplus"; + discriminator: [195, 56, 152, 9, 232, 72, 35, 22]; + }, + { + name: "evtProtocolWithdrawSurplus"; + discriminator: [109, 111, 28, 221, 134, 195, 230, 203]; + }, + { + name: "evtSwap"; + discriminator: [27, 60, 21, 213, 138, 170, 187, 147]; + }, + { + name: "evtSwap2"; + discriminator: [189, 66, 51, 168, 38, 80, 117, 153]; + }, + { + name: "evtUpdatePoolCreator"; + discriminator: [107, 225, 165, 237, 91, 158, 213, 220]; + }, + { + name: "evtVirtualPoolMetadata"; + discriminator: [188, 18, 72, 76, 195, 91, 38, 74]; + }, + { + name: "evtWithdrawLeftover"; + discriminator: [191, 189, 104, 143, 111, 156, 94, 229]; + }, + { + name: "evtWithdrawMigrationFee"; + discriminator: [26, 203, 84, 85, 161, 23, 100, 214]; + } + ]; + errors: [ + { + code: 6000; + name: "mathOverflow"; + msg: "Math operation overflow"; + }, + { + code: 6001; + name: "invalidFee"; + msg: "Invalid fee setup"; + }, + { + code: 6002; + name: "exceededSlippage"; + msg: "Exceeded slippage tolerance"; + }, + { + code: 6003; + name: "exceedMaxFeeBps"; + msg: "Exceeded max fee bps"; + }, + { + code: 6004; + name: "invalidAdmin"; + msg: "Invalid admin"; + }, + { + code: 6005; + name: "amountIsZero"; + msg: "Amount is zero"; + }, + { + code: 6006; + name: "typeCastFailed"; + msg: "Type cast error"; + }, + { + code: 6007; + name: "invalidActivationType"; + msg: "Invalid activation type"; + }, + { + code: 6008; + name: "invalidQuoteMint"; + msg: "Invalid quote mint"; + }, + { + code: 6009; + name: "invalidCollectFeeMode"; + msg: "Invalid collect fee mode"; + }, + { + code: 6010; + name: "invalidMigrationFeeOption"; + msg: "Invalid migration fee option"; + }, + { + code: 6011; + name: "invalidInput"; + msg: "Invalid input"; + }, + { + code: 6012; + name: "notEnoughLiquidity"; + msg: "Not enough liquidity"; + }, + { + code: 6013; + name: "poolIsCompleted"; + msg: "Pool is completed"; + }, + { + code: 6014; + name: "poolIsIncompleted"; + msg: "Pool is incompleted"; + }, + { + code: 6015; + name: "invalidMigrationOption"; + msg: "Invalid migration option"; + }, + { + code: 6016; + name: "invalidTokenDecimals"; + msg: "Invalid activation type"; + }, + { + code: 6017; + name: "invalidTokenType"; + msg: "Invalid token type"; + }, + { + code: 6018; + name: "invalidFeePercentage"; + msg: "Invalid fee percentage"; + }, + { + code: 6019; + name: "invalidQuoteThreshold"; + msg: "Invalid quote threshold"; + }, + { + code: 6020; + name: "invalidTokenSupply"; + msg: "Invalid token supply"; + }, + { + code: 6021; + name: "invalidCurve"; + msg: "Invalid curve"; + }, + { + code: 6022; + name: "notPermitToDoThisAction"; + msg: "Not permit to do this action"; + }, + { + code: 6023; + name: "invalidOwnerAccount"; + msg: "Invalid owner account"; + }, + { + code: 6024; + name: "invalidConfigAccount"; + msg: "Invalid config account"; + }, + { + code: 6025; + name: "surplusHasBeenWithdraw"; + msg: "Surplus has been withdraw"; + }, + { + code: 6026; + name: "leftoverHasBeenWithdraw"; + msg: "Leftover has been withdraw"; + }, + { + code: 6027; + name: "totalBaseTokenExceedMaxSupply"; + msg: "Total base token is exceeded max supply"; + }, + { + code: 6028; + name: "unsupportNativeMintToken2022"; + msg: "Unsupport native mint token 2022"; + }, + { + code: 6029; + name: "insufficientLiquidityForMigration"; + msg: "Insufficient liquidity for migration"; + }, + { + code: 6030; + name: "missingPoolConfigInRemainingAccount"; + msg: "Missing pool config in remaining account"; + }, + { + code: 6031; + name: "invalidVestingParameters"; + msg: "Invalid vesting parameters"; + }, + { + code: 6032; + name: "invalidLeftoverAddress"; + msg: "Invalid leftover address"; + }, + { + code: 6033; + name: "swapAmountIsOverAThreshold"; + msg: "Swap amount is over a threshold"; + }, + { + code: 6034; + name: "invalidFeeScheduler"; + msg: "Invalid fee scheduler"; + }, + { + code: 6035; + name: "invalidCreatorTradingFeePercentage"; + msg: "Invalid creator trading fee percentage"; + }, + { + code: 6036; + name: "invalidNewCreator"; + msg: "Invalid new creator"; + }, + { + code: 6037; + name: "invalidTokenAuthorityOption"; + msg: "Invalid token authority option"; + }, + { + code: 6038; + name: "invalidAccount"; + msg: "Invalid account for the instruction"; + }, + { + code: 6039; + name: "invalidMigratorFeePercentage"; + msg: "Invalid migrator fee percentage"; + }, + { + code: 6040; + name: "migrationFeeHasBeenWithdraw"; + msg: "Migration fee has been withdraw"; + }, + { + code: 6041; + name: "invalidBaseFeeMode"; + msg: "Invalid base fee mode"; + }, + { + code: 6042; + name: "invalidFeeRateLimiter"; + msg: "Invalid fee rate limiter"; + }, + { + code: 6043; + name: "failToValidateSingleSwapInstruction"; + msg: "Fail to validate single swap instruction in rate limiter"; + }, + { + code: 6044; + name: "invalidMigratedPoolFee"; + msg: "Invalid migrated pool fee params"; + }, + { + code: 6045; + name: "undeterminedError"; + msg: "Undertermined error"; + }, + { + code: 6046; + name: "rateLimiterNotSupported"; + msg: "Rate limiter not supported"; + }, + { + code: 6047; + name: "amountLeftIsNotZero"; + msg: "Amount left is not zero"; + }, + { + code: 6048; + name: "nextSqrtPriceIsSmallerThanStartSqrtPrice"; + msg: "Next sqrt price is smaller than start sqrt price"; + } + ]; + types: [ + { + name: "baseFeeConfig"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "cliffFeeNumerator"; + type: "u64"; + }, + { + name: "secondFactor"; + type: "u64"; + }, + { + name: "thirdFactor"; + type: "u64"; + }, + { + name: "firstFactor"; + type: "u16"; + }, + { + name: "baseFeeMode"; + type: "u8"; + }, + { + name: "padding0"; + type: { + array: ["u8", 5]; + }; + } + ]; + }; + }, + { + name: "baseFeeParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "cliffFeeNumerator"; + type: "u64"; + }, + { + name: "firstFactor"; + type: "u16"; + }, + { + name: "secondFactor"; + type: "u64"; + }, + { + name: "thirdFactor"; + type: "u64"; + }, + { + name: "baseFeeMode"; + type: "u8"; + } + ]; + }; + }, + { + name: "claimFeeOperator"; + docs: ["Parameter that set by the protocol"]; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "operator"; + docs: ["operator"]; + type: "pubkey"; + }, + { + name: "padding"; + docs: ["Reserve"]; + type: { + array: ["u8", 128]; + }; + } + ]; + }; + }, + { + name: "config"; + type: { + kind: "struct"; + fields: [ + { + name: "poolFees"; + type: { + defined: { + name: "poolFees"; + }; + }; + }, + { + name: "activationDuration"; + type: "u64"; + }, + { + name: "vaultConfigKey"; + type: "pubkey"; + }, + { + name: "poolCreatorAuthority"; + type: "pubkey"; + }, + { + name: "activationType"; + type: "u8"; + }, + { + name: "partnerFeeNumerator"; + type: "u64"; + }, + { + name: "padding"; + type: { + array: ["u8", 219]; + }; + } + ]; + }; + }, + { + name: "configParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "poolFees"; + type: { + defined: { + name: "poolFeeParameters"; + }; + }; + }, + { + name: "collectFeeMode"; + type: "u8"; + }, + { + name: "migrationOption"; + type: "u8"; + }, + { + name: "activationType"; + type: "u8"; + }, + { + name: "tokenType"; + type: "u8"; + }, + { + name: "tokenDecimal"; + type: "u8"; + }, + { + name: "partnerLpPercentage"; + type: "u8"; + }, + { + name: "partnerLockedLpPercentage"; + type: "u8"; + }, + { + name: "creatorLpPercentage"; + type: "u8"; + }, + { + name: "creatorLockedLpPercentage"; + type: "u8"; + }, + { + name: "migrationQuoteThreshold"; + type: "u64"; + }, + { + name: "sqrtStartPrice"; + type: "u128"; + }, + { + name: "lockedVesting"; + type: { + defined: { + name: "lockedVestingParams"; + }; + }; + }, + { + name: "migrationFeeOption"; + type: "u8"; + }, + { + name: "tokenSupply"; + type: { + option: { + defined: { + name: "tokenSupplyParams"; + }; + }; + }; + }, + { + name: "creatorTradingFeePercentage"; + type: "u8"; + }, + { + name: "tokenUpdateAuthority"; + type: "u8"; + }, + { + name: "migrationFee"; + type: { + defined: { + name: "migrationFee"; + }; + }; + }, + { + name: "migratedPoolFee"; + type: { + defined: { + name: "migratedPoolFee"; + }; + }; + }, + { + name: "padding"; + docs: ["padding for future use"]; + type: { + array: ["u64", 7]; + }; + }, + { + name: "curve"; + type: { + vec: { + defined: { + name: "liquidityDistributionParameters"; + }; + }; + }; + } + ]; + }; + }, + { + name: "createPartnerMetadataParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "padding"; + type: { + array: ["u8", 96]; + }; + }, + { + name: "name"; + type: "string"; + }, + { + name: "website"; + type: "string"; + }, + { + name: "logo"; + type: "string"; + } + ]; + }; + }, + { + name: "createVirtualPoolMetadataParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "padding"; + type: { + array: ["u8", 96]; + }; + }, + { + name: "name"; + type: "string"; + }, + { + name: "website"; + type: "string"; + }, + { + name: "logo"; + type: "string"; + } + ]; + }; + }, + { + name: "dynamicFeeConfig"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "initialized"; + type: "u8"; + }, + { + name: "padding"; + type: { + array: ["u8", 7]; + }; + }, + { + name: "maxVolatilityAccumulator"; + type: "u32"; + }, + { + name: "variableFeeControl"; + type: "u32"; + }, + { + name: "binStep"; + type: "u16"; + }, + { + name: "filterPeriod"; + type: "u16"; + }, + { + name: "decayPeriod"; + type: "u16"; + }, + { + name: "reductionFactor"; + type: "u16"; + }, + { + name: "padding2"; + type: { + array: ["u8", 8]; + }; + }, + { + name: "binStepU128"; + type: "u128"; + } + ]; + }; + }, + { + name: "dynamicFeeParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "binStep"; + type: "u16"; + }, + { + name: "binStepU128"; + type: "u128"; + }, + { + name: "filterPeriod"; + type: "u16"; + }, + { + name: "decayPeriod"; + type: "u16"; + }, + { + name: "reductionFactor"; + type: "u16"; + }, + { + name: "maxVolatilityAccumulator"; + type: "u32"; + }, + { + name: "variableFeeControl"; + type: "u32"; + } + ]; + }; + }, + { + name: "evtClaimCreatorTradingFee"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "tokenBaseAmount"; + type: "u64"; + }, + { + name: "tokenQuoteAmount"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtClaimProtocolFee"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "tokenBaseAmount"; + type: "u64"; + }, + { + name: "tokenQuoteAmount"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtClaimTradingFee"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "tokenBaseAmount"; + type: "u64"; + }, + { + name: "tokenQuoteAmount"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtCloseClaimFeeOperator"; + docs: ["Close claim fee operator"]; + type: { + kind: "struct"; + fields: [ + { + name: "claimFeeOperator"; + type: "pubkey"; + }, + { + name: "operator"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtCreateClaimFeeOperator"; + docs: ["Create claim fee operator"]; + type: { + kind: "struct"; + fields: [ + { + name: "operator"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtCreateConfig"; + docs: ["Create config"]; + type: { + kind: "struct"; + fields: [ + { + name: "config"; + type: "pubkey"; + }, + { + name: "quoteMint"; + type: "pubkey"; + }, + { + name: "feeClaimer"; + type: "pubkey"; + }, + { + name: "owner"; + type: "pubkey"; + }, + { + name: "poolFees"; + type: { + defined: { + name: "poolFeeParameters"; + }; + }; + }, + { + name: "collectFeeMode"; + type: "u8"; + }, + { + name: "migrationOption"; + type: "u8"; + }, + { + name: "activationType"; + type: "u8"; + }, + { + name: "tokenDecimal"; + type: "u8"; + }, + { + name: "tokenType"; + type: "u8"; + }, + { + name: "partnerLockedLpPercentage"; + type: "u8"; + }, + { + name: "partnerLpPercentage"; + type: "u8"; + }, + { + name: "creatorLockedLpPercentage"; + type: "u8"; + }, + { + name: "creatorLpPercentage"; + type: "u8"; + }, + { + name: "swapBaseAmount"; + type: "u64"; + }, + { + name: "migrationQuoteThreshold"; + type: "u64"; + }, + { + name: "migrationBaseAmount"; + type: "u64"; + }, + { + name: "sqrtStartPrice"; + type: "u128"; + }, + { + name: "lockedVesting"; + type: { + defined: { + name: "lockedVestingParams"; + }; + }; + }, + { + name: "migrationFeeOption"; + type: "u8"; + }, + { + name: "fixedTokenSupplyFlag"; + type: "u8"; + }, + { + name: "preMigrationTokenSupply"; + type: "u64"; + }, + { + name: "postMigrationTokenSupply"; + type: "u64"; + }, + { + name: "curve"; + type: { + vec: { + defined: { + name: "liquidityDistributionParameters"; + }; + }; + }; + } + ]; + }; + }, + { + name: "evtCreateConfigV2"; + type: { + kind: "struct"; + fields: [ + { + name: "config"; + type: "pubkey"; + }, + { + name: "quoteMint"; + type: "pubkey"; + }, + { + name: "feeClaimer"; + type: "pubkey"; + }, + { + name: "leftoverReceiver"; + type: "pubkey"; + }, + { + name: "configParameters"; + type: { + defined: { + name: "configParameters"; + }; + }; + } + ]; + }; + }, + { + name: "evtCreateDammV2MigrationMetadata"; + type: { + kind: "struct"; + fields: [ + { + name: "virtualPool"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtCreateMeteoraMigrationMetadata"; + type: { + kind: "struct"; + fields: [ + { + name: "virtualPool"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtCreatorWithdrawSurplus"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "surplusAmount"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtCurveComplete"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "config"; + type: "pubkey"; + }, + { + name: "baseReserve"; + type: "u64"; + }, + { + name: "quoteReserve"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtInitializePool"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "config"; + type: "pubkey"; + }, + { + name: "creator"; + type: "pubkey"; + }, + { + name: "baseMint"; + type: "pubkey"; + }, + { + name: "poolType"; + type: "u8"; + }, + { + name: "activationPoint"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtPartnerMetadata"; + docs: ["Create partner metadata"]; + type: { + kind: "struct"; + fields: [ + { + name: "partnerMetadata"; + type: "pubkey"; + }, + { + name: "feeClaimer"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtPartnerWithdrawMigrationFee"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "fee"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtPartnerWithdrawSurplus"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "surplusAmount"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtProtocolWithdrawSurplus"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "surplusAmount"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtSwap"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "config"; + type: "pubkey"; + }, + { + name: "tradeDirection"; + type: "u8"; + }, + { + name: "hasReferral"; + type: "bool"; + }, + { + name: "params"; + type: { + defined: { + name: "swapParameters"; + }; + }; + }, + { + name: "swapResult"; + type: { + defined: { + name: "swapResult"; + }; + }; + }, + { + name: "amountIn"; + type: "u64"; + }, + { + name: "currentTimestamp"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtSwap2"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "config"; + type: "pubkey"; + }, + { + name: "tradeDirection"; + type: "u8"; + }, + { + name: "hasReferral"; + type: "bool"; + }, + { + name: "swapParameters"; + type: { + defined: { + name: "swapParameters2"; + }; + }; + }, + { + name: "swapResult"; + type: { + defined: { + name: "swapResult2"; + }; + }; + }, + { + name: "quoteReserveAmount"; + type: "u64"; + }, + { + name: "migrationThreshold"; + type: "u64"; + }, + { + name: "currentTimestamp"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtUpdatePoolCreator"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "creator"; + type: "pubkey"; + }, + { + name: "newCreator"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtVirtualPoolMetadata"; + docs: ["Create virtual pool metadata"]; + type: { + kind: "struct"; + fields: [ + { + name: "virtualPoolMetadata"; + type: "pubkey"; + }, + { + name: "virtualPool"; + type: "pubkey"; + } + ]; + }; + }, + { + name: "evtWithdrawLeftover"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "leftoverReceiver"; + type: "pubkey"; + }, + { + name: "leftoverAmount"; + type: "u64"; + } + ]; + }; + }, + { + name: "evtWithdrawMigrationFee"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "fee"; + type: "u64"; + }, + { + name: "flag"; + type: "u8"; + } + ]; + }; + }, + { + name: "initializePoolParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "name"; + type: "string"; + }, + { + name: "symbol"; + type: "string"; + }, + { + name: "uri"; + type: "string"; + } + ]; + }; + }, + { + name: "liquidityDistributionConfig"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "sqrtPrice"; + type: "u128"; + }, + { + name: "liquidity"; + type: "u128"; + } + ]; + }; + }, + { + name: "liquidityDistributionParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "sqrtPrice"; + type: "u128"; + }, + { + name: "liquidity"; + type: "u128"; + } + ]; + }; + }, + { + name: "lockEscrow"; + docs: ["State of lock escrow account"]; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "owner"; + type: "pubkey"; + }, + { + name: "escrowVault"; + type: "pubkey"; + }, + { + name: "bump"; + type: "u8"; + }, + { + name: "totalLockedAmount"; + type: "u64"; + }, + { + name: "lpPerToken"; + type: "u128"; + }, + { + name: "unclaimedFeePending"; + type: "u64"; + }, + { + name: "aFee"; + type: "u64"; + }, + { + name: "bFee"; + type: "u64"; + } + ]; + }; + }, + { + name: "lockedVestingConfig"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "amountPerPeriod"; + type: "u64"; + }, + { + name: "cliffDurationFromMigrationTime"; + type: "u64"; + }, + { + name: "frequency"; + type: "u64"; + }, + { + name: "numberOfPeriod"; + type: "u64"; + }, + { + name: "cliffUnlockAmount"; + type: "u64"; + }, + { + name: "padding"; + type: "u64"; + } + ]; + }; + }, + { + name: "lockedVestingParams"; + type: { + kind: "struct"; + fields: [ + { + name: "amountPerPeriod"; + type: "u64"; + }, + { + name: "cliffDurationFromMigrationTime"; + type: "u64"; + }, + { + name: "frequency"; + type: "u64"; + }, + { + name: "numberOfPeriod"; + type: "u64"; + }, + { + name: "cliffUnlockAmount"; + type: "u64"; + } + ]; + }; + }, + { + name: "meteoraDammMigrationMetadata"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "virtualPool"; + docs: ["pool"]; + type: "pubkey"; + }, + { + name: "padding0"; + docs: [ + "!!! BE CAREFUL to use tomestone field, previous is pool creator" + ]; + type: { + array: ["u8", 32]; + }; + }, + { + name: "partner"; + docs: ["partner"]; + type: "pubkey"; + }, + { + name: "lpMint"; + docs: ["lp mint"]; + type: "pubkey"; + }, + { + name: "partnerLockedLp"; + docs: ["partner locked lp"]; + type: "u64"; + }, + { + name: "partnerLp"; + docs: ["partner lp"]; + type: "u64"; + }, + { + name: "creatorLockedLp"; + docs: ["creator locked lp"]; + type: "u64"; + }, + { + name: "creatorLp"; + docs: ["creator lp"]; + type: "u64"; + }, + { + name: "padding0"; + docs: ["padding"]; + type: "u8"; + }, + { + name: "creatorLockedStatus"; + docs: ["flag to check whether lp is locked for creator"]; + type: "u8"; + }, + { + name: "partnerLockedStatus"; + docs: ["flag to check whether lp is locked for partner"]; + type: "u8"; + }, + { + name: "creatorClaimStatus"; + docs: ["flag to check whether creator has claimed lp token"]; + type: "u8"; + }, + { + name: "partnerClaimStatus"; + docs: ["flag to check whether partner has claimed lp token"]; + type: "u8"; + }, + { + name: "padding"; + docs: ["Reserve"]; + type: { + array: ["u8", 107]; + }; + } + ]; + }; + }, + { + name: "meteoraDammV2Metadata"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "virtualPool"; + docs: ["pool"]; + type: "pubkey"; + }, + { + name: "padding0"; + docs: [ + "!!! BE CAREFUL to use tomestone field, previous is pool creator" + ]; + type: { + array: ["u8", 32]; + }; + }, + { + name: "partner"; + docs: ["partner"]; + type: "pubkey"; + }, + { + name: "padding"; + docs: ["Reserve"]; + type: { + array: ["u8", 126]; + }; + } + ]; + }; + }, + { + name: "migratedPoolFee"; + type: { + kind: "struct"; + fields: [ + { + name: "collectFeeMode"; + type: "u8"; + }, + { + name: "dynamicFee"; + type: "u8"; + }, + { + name: "poolFeeBps"; + type: "u16"; + } + ]; + }; + }, + { + name: "migrationFee"; + type: { + kind: "struct"; + fields: [ + { + name: "feePercentage"; + type: "u8"; + }, + { + name: "creatorFeePercentage"; + type: "u8"; + } + ]; + }; + }, + { + name: "partnerMetadata"; + docs: ["Metadata for a partner."]; + type: { + kind: "struct"; + fields: [ + { + name: "feeClaimer"; + docs: ["fee claimer"]; + type: "pubkey"; + }, + { + name: "padding"; + docs: ["padding for future use"]; + type: { + array: ["u128", 6]; + }; + }, + { + name: "name"; + docs: ["Name of partner."]; + type: "string"; + }, + { + name: "website"; + docs: ["Website of partner."]; + type: "string"; + }, + { + name: "logo"; + docs: ["Logo of partner"]; + type: "string"; + } + ]; + }; + }, + { + name: "poolConfig"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "quoteMint"; + docs: ["quote mint"]; + type: "pubkey"; + }, + { + name: "feeClaimer"; + docs: ["Address to get the fee"]; + type: "pubkey"; + }, + { + name: "leftoverReceiver"; + docs: [ + "Address to receive extra base token after migration, in case token is fixed supply" + ]; + type: "pubkey"; + }, + { + name: "poolFees"; + docs: ["Pool fee"]; + type: { + defined: { + name: "poolFeesConfig"; + }; + }; + }, + { + name: "collectFeeMode"; + docs: ["Collect fee mode"]; + type: "u8"; + }, + { + name: "migrationOption"; + docs: ["migration option"]; + type: "u8"; + }, + { + name: "activationType"; + docs: ["whether mode slot or timestamp"]; + type: "u8"; + }, + { + name: "tokenDecimal"; + docs: ["token decimals"]; + type: "u8"; + }, + { + name: "version"; + docs: ["version"]; + type: "u8"; + }, + { + name: "tokenType"; + docs: ["token type of base token"]; + type: "u8"; + }, + { + name: "quoteTokenFlag"; + docs: ["quote token flag"]; + type: "u8"; + }, + { + name: "partnerLockedLpPercentage"; + docs: ["partner locked lp percentage"]; + type: "u8"; + }, + { + name: "partnerLpPercentage"; + docs: ["partner lp percentage"]; + type: "u8"; + }, + { + name: "creatorLockedLpPercentage"; + docs: ["creator post migration fee percentage"]; + type: "u8"; + }, + { + name: "creatorLpPercentage"; + docs: ["creator lp percentage"]; + type: "u8"; + }, + { + name: "migrationFeeOption"; + docs: ["migration fee option"]; + type: "u8"; + }, + { + name: "fixedTokenSupplyFlag"; + docs: [ + "flag to indicate whether token is dynamic supply (0) or fixed supply (1)" + ]; + type: "u8"; + }, + { + name: "creatorTradingFeePercentage"; + docs: ["creator trading fee percentage"]; + type: "u8"; + }, + { + name: "tokenUpdateAuthority"; + docs: ["token update authority"]; + type: "u8"; + }, + { + name: "migrationFeePercentage"; + docs: ["migration fee percentage"]; + type: "u8"; + }, + { + name: "creatorMigrationFeePercentage"; + docs: ["creator migration fee percentage"]; + type: "u8"; + }, + { + name: "padding0"; + docs: ["padding 0"]; + type: { + array: ["u8", 7]; + }; + }, + { + name: "swapBaseAmount"; + docs: ["swap base amount"]; + type: "u64"; + }, + { + name: "migrationQuoteThreshold"; + docs: ["migration quote threshold (in quote token)"]; + type: "u64"; + }, + { + name: "migrationBaseThreshold"; + docs: ["migration base threshold (in base token)"]; + type: "u64"; + }, + { + name: "migrationSqrtPrice"; + docs: ["migration sqrt price"]; + type: "u128"; + }, + { + name: "lockedVestingConfig"; + docs: ["locked vesting config"]; + type: { + defined: { + name: "lockedVestingConfig"; + }; + }; + }, + { + name: "preMigrationTokenSupply"; + docs: ["pre migration token supply"]; + type: "u64"; + }, + { + name: "postMigrationTokenSupply"; + docs: ["post migration token supply"]; + type: "u64"; + }, + { + name: "migratedCollectFeeMode"; + docs: ["migrated pool collect fee mode"]; + type: "u8"; + }, + { + name: "migratedDynamicFee"; + docs: ["migrated dynamic fee option."]; + type: "u8"; + }, + { + name: "migratedPoolFeeBps"; + docs: ["migrated pool fee in bps"]; + type: "u16"; + }, + { + name: "padding1"; + docs: ["padding 1"]; + type: { + array: ["u8", 12]; + }; + }, + { + name: "padding2"; + docs: ["padding 2"]; + type: "u128"; + }, + { + name: "sqrtStartPrice"; + docs: ["minimum price"]; + type: "u128"; + }, + { + name: "curve"; + docs: [ + "curve, only use 20 point firstly, we can extend that latter" + ]; + type: { + array: [ + { + defined: { + name: "liquidityDistributionConfig"; + }; + }, + 20 + ]; + }; + } + ]; + }; + }, + { + name: "poolFeeParameters"; + docs: ["Information regarding fee charges"]; + type: { + kind: "struct"; + fields: [ + { + name: "baseFee"; + docs: ["Base fee"]; + type: { + defined: { + name: "baseFeeParameters"; + }; + }; + }, + { + name: "dynamicFee"; + docs: ["dynamic fee"]; + type: { + option: { + defined: { + name: "dynamicFeeParameters"; + }; + }; + }; + } + ]; + }; + }, + { + name: "poolFees"; + docs: ["Information regarding fee charges"]; + type: { + kind: "struct"; + fields: [ + { + name: "tradeFeeNumerator"; + type: "u64"; + }, + { + name: "tradeFeeDenominator"; + type: "u64"; + }, + { + name: "protocolTradeFeeNumerator"; + type: "u64"; + }, + { + name: "protocolTradeFeeDenominator"; + type: "u64"; + } + ]; + }; + }, + { + name: "poolFeesConfig"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "baseFee"; + type: { + defined: { + name: "baseFeeConfig"; + }; + }; + }, + { + name: "dynamicFee"; + type: { + defined: { + name: "dynamicFeeConfig"; + }; + }; + }, + { + name: "padding0"; + type: { + array: ["u64", 5]; + }; + }, + { + name: "padding1"; + type: { + array: ["u8", 6]; + }; + }, + { + name: "protocolFeePercent"; + type: "u8"; + }, + { + name: "referralFeePercent"; + type: "u8"; + } + ]; + }; + }, + { + name: "poolMetrics"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "totalProtocolBaseFee"; + type: "u64"; + }, + { + name: "totalProtocolQuoteFee"; + type: "u64"; + }, + { + name: "totalTradingBaseFee"; + type: "u64"; + }, + { + name: "totalTradingQuoteFee"; + type: "u64"; + } + ]; + }; + }, + { + name: "swapParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "amountIn"; + type: "u64"; + }, + { + name: "minimumAmountOut"; + type: "u64"; + } + ]; + }; + }, + { + name: "swapParameters2"; + type: { + kind: "struct"; + fields: [ + { + name: "amount0"; + docs: [ + "When it's exact in, partial fill, this will be amount_in. When it's exact out, this will be amount_out" + ]; + type: "u64"; + }, + { + name: "amount1"; + docs: [ + "When it's exact in, partial fill, this will be minimum_amount_out. When it's exact out, this will be maximum_amount_in" + ]; + type: "u64"; + }, + { + name: "swapMode"; + docs: ["Swap mode, refer [SwapMode]"]; + type: "u8"; + } + ]; + }; + }, + { + name: "swapResult"; + docs: ["Encodes all results of swapping"]; + type: { + kind: "struct"; + fields: [ + { + name: "actualInputAmount"; + type: "u64"; + }, + { + name: "outputAmount"; + type: "u64"; + }, + { + name: "nextSqrtPrice"; + type: "u128"; + }, + { + name: "tradingFee"; + type: "u64"; + }, + { + name: "protocolFee"; + type: "u64"; + }, + { + name: "referralFee"; + type: "u64"; + } + ]; + }; + }, + { + name: "swapResult2"; + type: { + kind: "struct"; + fields: [ + { + name: "includedFeeInputAmount"; + type: "u64"; + }, + { + name: "excludedFeeInputAmount"; + type: "u64"; + }, + { + name: "amountLeft"; + type: "u64"; + }, + { + name: "outputAmount"; + type: "u64"; + }, + { + name: "nextSqrtPrice"; + type: "u128"; + }, + { + name: "tradingFee"; + type: "u64"; + }, + { + name: "protocolFee"; + type: "u64"; + }, + { + name: "referralFee"; + type: "u64"; + } + ]; + }; + }, + { + name: "tokenSupplyParams"; + type: { + kind: "struct"; + fields: [ + { + name: "preMigrationTokenSupply"; + docs: ["pre migration token supply"]; + type: "u64"; + }, + { + name: "postMigrationTokenSupply"; + docs: [ + "post migration token supply", + "becase DBC allow user to swap over the migration quote threshold, so in extreme case user may swap more than allowed buffer on curve", + "that result the total supply in post migration may be increased a bit (between pre_migration_token_supply and post_migration_token_supply)" + ]; + type: "u64"; + } + ]; + }; + }, + { + name: "virtualPool"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "volatilityTracker"; + docs: ["volatility tracker"]; + type: { + defined: { + name: "volatilityTracker"; + }; + }; + }, + { + name: "config"; + docs: ["config key"]; + type: "pubkey"; + }, + { + name: "creator"; + docs: ["creator"]; + type: "pubkey"; + }, + { + name: "baseMint"; + docs: ["base mint"]; + type: "pubkey"; + }, + { + name: "baseVault"; + docs: ["base vault"]; + type: "pubkey"; + }, + { + name: "quoteVault"; + docs: ["quote vault"]; + type: "pubkey"; + }, + { + name: "baseReserve"; + docs: ["base reserve"]; + type: "u64"; + }, + { + name: "quoteReserve"; + docs: ["quote reserve"]; + type: "u64"; + }, + { + name: "protocolBaseFee"; + docs: ["protocol base fee"]; + type: "u64"; + }, + { + name: "protocolQuoteFee"; + docs: ["protocol quote fee"]; + type: "u64"; + }, + { + name: "partnerBaseFee"; + docs: ["partner base fee"]; + type: "u64"; + }, + { + name: "partnerQuoteFee"; + docs: ["trading quote fee"]; + type: "u64"; + }, + { + name: "sqrtPrice"; + docs: ["current price"]; + type: "u128"; + }, + { + name: "activationPoint"; + docs: ["Activation point"]; + type: "u64"; + }, + { + name: "poolType"; + docs: ["pool type, spl token or token2022"]; + type: "u8"; + }, + { + name: "isMigrated"; + docs: ["is migrated"]; + type: "u8"; + }, + { + name: "isPartnerWithdrawSurplus"; + docs: ["is partner withdraw surplus"]; + type: "u8"; + }, + { + name: "isProtocolWithdrawSurplus"; + docs: ["is protocol withdraw surplus"]; + type: "u8"; + }, + { + name: "migrationProgress"; + docs: ["migration progress"]; + type: "u8"; + }, + { + name: "isWithdrawLeftover"; + docs: ["is withdraw leftover"]; + type: "u8"; + }, + { + name: "isCreatorWithdrawSurplus"; + docs: ["is creator withdraw surplus"]; + type: "u8"; + }, + { + name: "migrationFeeWithdrawStatus"; + docs: [ + "migration fee withdraw status, first bit is for partner, second bit is for creator" + ]; + type: "u8"; + }, + { + name: "metrics"; + docs: ["pool metrics"]; + type: { + defined: { + name: "poolMetrics"; + }; + }; + }, + { + name: "finishCurveTimestamp"; + docs: ["The time curve is finished"]; + type: "u64"; + }, + { + name: "creatorBaseFee"; + docs: ["creator base fee"]; + type: "u64"; + }, + { + name: "creatorQuoteFee"; + docs: ["creator quote fee"]; + type: "u64"; + }, + { + name: "padding1"; + docs: ["Padding for further use"]; + type: { + array: ["u64", 7]; + }; + } + ]; + }; + }, + { + name: "virtualPoolMetadata"; + docs: ["Metadata for a virtual pool."]; + type: { + kind: "struct"; + fields: [ + { + name: "virtualPool"; + docs: ["virtual pool"]; + type: "pubkey"; + }, + { + name: "padding"; + docs: ["padding for future use"]; + type: { + array: ["u128", 6]; + }; + }, + { + name: "name"; + docs: ["Name of project."]; + type: "string"; + }, + { + name: "website"; + docs: ["Website of project."]; + type: "string"; + }, + { + name: "logo"; + docs: ["Logo of project"]; + type: "string"; + } + ]; + }; + }, + { + name: "volatilityTracker"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "lastUpdateTimestamp"; + type: "u64"; + }, + { + name: "padding"; + type: { + array: ["u8", 8]; + }; + }, + { + name: "sqrtPriceReference"; + type: "u128"; + }, + { + name: "volatilityAccumulator"; + type: "u128"; + }, + { + name: "volatilityReference"; + type: "u128"; + } + ]; + }; + } + ]; +}; diff --git a/tests/common/index.ts b/tests/common/index.ts index bbff817..6ba8c02 100644 --- a/tests/common/index.ts +++ b/tests/common/index.ts @@ -16,10 +16,12 @@ import DynamicFeeSharingIDL from "../../target/idl/dynamic_fee_sharing.json"; import { DynamicFeeSharing } from "../../target/types/dynamic_fee_sharing"; import { createAssociatedTokenAccountInstruction, + createCloseAccountInstruction, createInitializeMint2Instruction, createMintToInstruction, getAssociatedTokenAddressSync, MINT_SIZE, + NATIVE_MINT, TOKEN_PROGRAM_ID, } from "@solana/spl-token"; import { @@ -30,11 +32,8 @@ import { PublicKey, SystemProgram, Transaction, + TransactionInstruction, } from "@solana/web3.js"; -import { - TransactionErrorFieldless, - TransactionErrorInstructionError, -} from "litesvm/dist/internal"; export type InitializeFeeVaultParameters = IdlTypes["initializeFeeVaultParameters"]; @@ -46,6 +45,10 @@ export type DynamicFeeSharingProgram = Program; export const TOKEN_DECIMALS = 9; export const RAW_AMOUNT = 1_000_000_000 * 10 ** TOKEN_DECIMALS; +export const DYNAMIC_FEE_SHARING_PROGRAM_ID = new PublicKey( + DynamicFeeSharingIDL.address +); +export const U64_MAX = new BN("18446744073709551615"); export function createProgram(): DynamicFeeSharingProgram { const wallet = new Wallet(Keypair.generate()); @@ -134,7 +137,8 @@ export function mintToken( payer: Keypair, mint: PublicKey, mintAuthority: Keypair, - toWallet: PublicKey + toWallet: PublicKey, + amount?: number ) { const destination = getOrCreateAtA(svm, payer, mint, toWallet); @@ -142,7 +146,7 @@ export function mintToken( mint, destination, mintAuthority.publicKey, - RAW_AMOUNT + amount ?? RAW_AMOUNT ); let transaction = new Transaction(); @@ -182,6 +186,53 @@ export function getOrCreateAtA( return ataKey; } +export const wrapSOLInstruction = ( + from: PublicKey, + to: PublicKey, + amount: bigint +): TransactionInstruction[] => { + return [ + SystemProgram.transfer({ + fromPubkey: from, + toPubkey: to, + lamports: amount, + }), + new TransactionInstruction({ + keys: [ + { + pubkey: to, + isSigner: false, + isWritable: true, + }, + ], + data: Buffer.from(new Uint8Array([17])), + programId: TOKEN_PROGRAM_ID, + }), + ]; +}; + +export const unwrapSOLInstruction = ( + owner: PublicKey, + allowOwnerOffCurve = true +) => { + const wSolATAAccount = getAssociatedTokenAddressSync( + NATIVE_MINT, + owner, + allowOwnerOffCurve + ); + if (wSolATAAccount) { + const closedWrappedSolInstruction = createCloseAccountInstruction( + wSolATAAccount, + owner, + owner, + [], + TOKEN_PROGRAM_ID + ); + return closedWrappedSolInstruction; + } + return null; +}; + export function generateUsers(svm: LiteSVM, numberOfUsers: number) { const res = []; for (let i = 0; i < numberOfUsers; i++) { diff --git a/tests/common/svm.ts b/tests/common/svm.ts new file mode 100644 index 0000000..fb5152c --- /dev/null +++ b/tests/common/svm.ts @@ -0,0 +1,116 @@ +import { + Keypair, + LAMPORTS_PER_SOL, + PublicKey, + SystemProgram, + Transaction, +} from "@solana/web3.js"; + +import { + AccountInfoBytes, + FailedTransactionMetadata, + LiteSVM, + TransactionMetadata, +} from "litesvm"; +import { DYNAMIC_FEE_SHARING_PROGRAM_ID } from "./index"; +import { expect } from "chai"; +import BN from "bn.js"; +import { DAMM_V2_PROGRAM_ID } from "./damm_v2"; +import { AccountLayout } from "@solana/spl-token"; +import { DBC_PROGRAM_ID } from "./dbc"; + +export function startSvm() { + const svm = new LiteSVM(); + svm.addProgramFromFile( + new PublicKey(DYNAMIC_FEE_SHARING_PROGRAM_ID), + "./target/deploy/dynamic_fee_sharing.so" + ); + + svm.addProgramFromFile( + new PublicKey(DAMM_V2_PROGRAM_ID), + "./tests/fixtures/damm_v2.so" + ); + + svm.addProgramFromFile( + new PublicKey(DBC_PROGRAM_ID), + "./tests/fixtures/dynamic_bonding_curve.so" + ); + + const accountInfo: AccountInfoBytes = { + data: new Uint8Array(), + executable: false, + lamports: 1200626308, + owner: SystemProgram.programId, + }; + + svm.setAccount( + new PublicKey("4EWqcx3aNZmMetCnxwLYwyNjan6XLGp3Ca2W316vrSjv"), + accountInfo + ); + + return svm; +} + +export function sendTransactionOrExpectThrowError( + svm: LiteSVM, + transaction: Transaction, + logging = false, + errorCode?: number +) { + const result = svm.sendTransaction(transaction); + if (logging) { + if (result instanceof TransactionMetadata) { + console.log(result.logs()); + } else { + console.log(result.meta().logs()); + } + } + if (errorCode) { + expectThrowsErrorCode(result, errorCode); + } else { + expect(result).instanceOf(TransactionMetadata); + } + + return result +} + +export function generateUsers(svm: LiteSVM, numberOfUsers: number): Keypair[] { + const res = []; + for (let i = 0; i < numberOfUsers; i++) { + const user = Keypair.generate(); + svm.airdrop(user.publicKey, BigInt(LAMPORTS_PER_SOL)); + res.push(user); + } + + return res; +} + +export function expectThrowsErrorCode( + response: TransactionMetadata | FailedTransactionMetadata, + errorCode: number +) { + if (response instanceof FailedTransactionMetadata) { + const message = response.err().toString(); + + if (!message.toString().includes(errorCode.toString())) { + throw new Error( + `Unexpected error: ${message}. Expected error: ${errorCode}` + ); + } + + return; + } else { + throw new Error("Expected an error but didn't get one"); + } +} + +export function warpToTimestamp(svm: LiteSVM, timestamp: BN) { + let clock = svm.getClock(); + clock.unixTimestamp = BigInt(timestamp.toString()); + svm.setClock(clock); +} + +export function getTokenBalance(svm: LiteSVM, ataAccount: PublicKey): BN { + const account = svm.getAccount(ataAccount); + return new BN(AccountLayout.decode(account.data).amount.toString()); +} diff --git a/tests/fee_sharing.test.ts b/tests/fee_sharing.test.ts index ad529a9..1a161ad 100644 --- a/tests/fee_sharing.test.ts +++ b/tests/fee_sharing.test.ts @@ -13,7 +13,7 @@ import { getProgramErrorCodeHexString, InitializeFeeVaultParameters, mintToken, - TOKEN_DECIMALS + TOKEN_DECIMALS, } from "./common"; import { TOKEN_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token"; import { BN } from "bn.js"; @@ -190,7 +190,10 @@ async function fullFlow( expect(feeVaultState.owner.toString()).eq(vaultOwner.toString()); expect(feeVaultState.tokenMint.toString()).eq(tokenMint.toString()); expect(feeVaultState.tokenVault.toString()).eq(tokenVault.toString()); - const totalShare = params.users.reduce((a, b) => a.add(new BN(b.share)), new BN(0)); + const totalShare = params.users.reduce( + (a, b) => a.add(new BN(b.share)), + new BN(0) + ); expect(feeVaultState.totalShare).eq(totalShare.toNumber()); expect(feeVaultState.totalFundedFee.toNumber()).eq(0); diff --git a/tests/fee_sharing_pda.test.ts b/tests/fee_sharing_pda.test.ts index b91595d..9532588 100644 --- a/tests/fee_sharing_pda.test.ts +++ b/tests/fee_sharing_pda.test.ts @@ -196,7 +196,10 @@ async function fullFlow( expect(feeVaultState.owner.toString()).eq(vaultOwner.toString()); expect(feeVaultState.tokenMint.toString()).eq(tokenMint.toString()); expect(feeVaultState.tokenVault.toString()).eq(tokenVault.toString()); - const totalShare = params.users.reduce((a, b) => a.add(new BN(b.share)), new BN(0)); + const totalShare = params.users.reduce( + (a, b) => a.add(new BN(b.share)), + new BN(0) + ); expect(feeVaultState.totalShare).eq(totalShare.toNumber()); expect(feeVaultState.totalFundedFee.toNumber()).eq(0); diff --git a/tests/fixtures/damm_v2.so b/tests/fixtures/damm_v2.so new file mode 100755 index 0000000..f427590 Binary files /dev/null and b/tests/fixtures/damm_v2.so differ diff --git a/tests/fixtures/dynamic_bonding_curve.so b/tests/fixtures/dynamic_bonding_curve.so new file mode 100755 index 0000000..6a3b548 Binary files /dev/null and b/tests/fixtures/dynamic_bonding_curve.so differ