diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d5f4be..a9dfbe1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,8 @@ on: pull_request: branches: - main + - release_0.2.0 + - zap_in env: SOLANA_CLI_VERSION: 2.1.0 diff --git a/.gitignore b/.gitignore index 2e0446b..fe66e7c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ target node_modules test-ledger .yarn +deploy.sh \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..4ac3a85 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,27 @@ +# 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 + +## zap [0.2.0] [PR #15](https://github.com/MeteoraAg/zap-program/pull/15) + +### Added +New endpoints `initialize_ledger_account`, `close_ledger_account`, `set_ledger_balance`, `update_ledger_balance_after_swap`, `zap_in_damm_v2`, `zap_in_dlmm_for_initialized_position` and `zap_in_dlmm_for_uninitialized_position` that allow user to zap in damm v2 and dlmm easily. Refer `ZAPIN.md` for zap_in examples diff --git a/Cargo.lock b/Cargo.lock index 783f6eb..7538b16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,6 +59,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "alloy-rlp" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f70d83b765fdc080dbcd4f4db70d8d23fe4761f2f02ebfa9146b833900634b4" +dependencies = [ + "arrayvec", + "bytes", +] + [[package]] name = "anchor-attribute-access-control" version = "0.31.1" @@ -259,6 +269,130 @@ version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" +[[package]] +name = "ark-ff" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +dependencies = [ + "ark-ff-asm 0.3.0", + "ark-ff-macros 0.3.0", + "ark-serialize 0.3.0", + "ark-std 0.3.0", + "derivative", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.3.3", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm 0.4.2", + "ark-ff-macros 0.4.2", + "ark-serialize 0.4.2", + "ark-std 0.4.0", + "derivative", + "digest 0.10.7", + "itertools 0.10.5", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.4.1", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" +dependencies = [ + "num-bigint", + "num-traits", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-serialize" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +dependencies = [ + "ark-std 0.3.0", + "digest 0.9.0", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-std 0.4.0", + "digest 0.10.7", + "num-bigint", +] + +[[package]] +name = "ark-std" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + [[package]] name = "arrayref" version = "0.3.9" @@ -271,6 +405,17 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +[[package]] +name = "auto_impl" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdcb70bdbc4d478427380519163274ac86e52916e10f0a8889adf0f96d3fee7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "autocfg" version = "1.5.0" @@ -310,6 +455,18 @@ version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "blake3" version = "1.8.2" @@ -435,6 +592,12 @@ dependencies = [ "serde", ] +[[package]] +name = "byte-slice-cast" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7575182f7272186991736b70173b0ea045398f984bf5ebbb3804736ce1330c9d" + [[package]] name = "bytemuck" version = "1.23.1" @@ -461,6 +624,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "bytes" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" + [[package]] name = "cargo_toml" version = "0.19.2" @@ -522,12 +691,59 @@ 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 = "const_format" +version = "0.2.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7faa7469a93a566e9ccc1c73fe783b4a65c274c5ace346038dca9c39fe0030ad" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "constant_time_eq" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" +[[package]] +name = "cp-amm" +version = "0.1.5" +source = "git+https://github.com/MeteoraAg/damm-v2?rev=689a3264484799d833c505523f4ff4e4990690aa#689a3264484799d833c505523f4ff4e4990690aa" +dependencies = [ + "anchor-lang", + "anchor-spl", + "bytemuck", + "const-crypto", + "num", + "num-traits", + "num_enum", + "ruint", + "spl-token-metadata-interface", + "static_assertions", +] + [[package]] name = "cpufeatures" version = "0.2.17" @@ -575,7 +791,7 @@ dependencies = [ "digest 0.10.7", "fiat-crypto", "rand_core 0.6.4", - "rustc_version", + "rustc_version 0.4.1", "serde", "subtle", "zeroize", @@ -598,6 +814,17 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e5c37193a1db1d8ed868c03ec7b152175f26160a5b740e5e484143877e0adf0" +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "digest" version = "0.9.0" @@ -618,6 +845,14 @@ dependencies = [ "subtle", ] +[[package]] +name = "dlmm" +version = "0.10.1" +dependencies = [ + "anchor-lang", + "bytemuck", +] + [[package]] name = "either" version = "1.15.0" @@ -630,6 +865,28 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +[[package]] +name = "fastrlp" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", +] + +[[package]] +name = "fastrlp" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce8dba4714ef14b8274c371879b175aa55b16b30f269663f19d576f380018dc4" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", +] + [[package]] name = "feature-probe" version = "0.1.1" @@ -666,12 +923,30 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2551bf44bc5f776c15044b9b94153a00198be06743e262afaaa61f11ac7523a5" +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "byteorder", + "rand 0.8.5", + "rustc-hex", + "static_assertions", +] + [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "generic-array" version = "0.14.7" @@ -706,6 +981,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + [[package]] name = "hashbrown" version = "0.13.2" @@ -730,6 +1017,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "hmac" version = "0.12.1" @@ -739,6 +1032,26 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "indexmap" version = "2.10.0" @@ -758,6 +1071,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.12.1" @@ -792,6 +1114,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" @@ -804,6 +1132,12 @@ version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" +[[package]] +name = "libm" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" + [[package]] name = "libsecp256k1" version = "0.6.0" @@ -893,6 +1227,20 @@ dependencies = [ "zeroize", ] +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + [[package]] name = "num-bigint" version = "0.4.6" @@ -903,6 +1251,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + [[package]] name = "num-derive" version = "0.4.2" @@ -923,6 +1280,28 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -930,6 +1309,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -966,6 +1346,34 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "parity-scale-codec" +version = "3.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799781ae679d79a948e13d4824a40970bfa500058d245760dd857301059810fa" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "const_format", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "rustversion", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34b4653168b563151153c9e4c08ebed57fb8262bebfa79711552fa983c623e7a" +dependencies = [ + "proc-macro-crate 3.3.0", + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "parking_lot" version = "0.12.4" @@ -989,6 +1397,12 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "pbkdf2" version = "0.11.0" @@ -1004,6 +1418,16 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pest" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "989e7521a040efde50c3ab6bbadafbe15ab6dc042686926be59ac35d74607df4" +dependencies = [ + "memchr", + "ucd-trie", +] + [[package]] name = "polyval" version = "0.6.2" @@ -1025,6 +1449,17 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "primitive-types" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +dependencies = [ + "fixed-hash", + "impl-codec", + "uint", +] + [[package]] name = "proc-macro-crate" version = "0.1.5" @@ -1052,6 +1487,21 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proptest" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee689443a2bd0a16ab0348b52ee43e3b2d1b1f931c8aa5c9f8de4c86fbe8c40" +dependencies = [ + "bitflags", + "num-traits", + "rand 0.9.2", + "rand_chacha 0.9.0", + "rand_xorshift", + "regex-syntax", + "unarray", +] + [[package]] name = "qstring" version = "0.7.2" @@ -1070,6 +1520,18 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.7.3" @@ -1094,6 +1556,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -1114,6 +1586,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + [[package]] name = "rand_core" version = "0.5.1" @@ -1132,6 +1614,15 @@ dependencies = [ "getrandom 0.2.16", ] +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.4", +] + [[package]] name = "rand_hc" version = "0.2.0" @@ -1141,6 +1632,15 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_xorshift" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a" +dependencies = [ + "rand_core 0.9.3", +] + [[package]] name = "redox_syscall" version = "0.5.14" @@ -1179,13 +1679,71 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rustc-hex", +] + +[[package]] +name = "ruint" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ecb38f82477f20c5c3d62ef52d7c4e536e38ea9b73fb570a20c5cae0e14bcf6" +dependencies = [ + "alloy-rlp", + "ark-ff 0.3.0", + "ark-ff 0.4.2", + "bytes", + "fastrlp 0.3.1", + "fastrlp 0.4.0", + "num-bigint", + "num-integer", + "num-traits", + "parity-scale-codec", + "primitive-types", + "proptest", + "rand 0.8.5", + "rand 0.9.2", + "rlp", + "ruint-macro", + "serde", + "valuable", + "zeroize", +] + +[[package]] +name = "ruint-macro" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + [[package]] name = "rustc_version" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ - "semver", + "semver 1.0.26", ] [[package]] @@ -1206,12 +1764,30 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + [[package]] name = "semver" version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +[[package]] +name = "semver-parser" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9900206b54a3527fdc7b8a938bffd94a568bac4f4aa8113b209df75a09c0dec2" +dependencies = [ + "pest", +] + [[package]] name = "serde" version = "1.0.219" @@ -1286,6 +1862,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" @@ -2185,7 +2767,7 @@ dependencies = [ "bytemuck", "bytemuck_derive", "curve25519-dalek", - "itertools", + "itertools 0.12.1", "js-sys", "merlin", "num-derive", @@ -2528,6 +3110,12 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "subtle" version = "2.6.1" @@ -2556,6 +3144,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "thiserror" version = "1.0.69" @@ -2667,6 +3261,30 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + [[package]] name = "unicode-ident" version = "1.0.18" @@ -2679,6 +3297,12 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + [[package]] name = "universal-hash" version = "0.5.1" @@ -2699,6 +3323,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + [[package]] name = "version_check" version = "0.9.5" @@ -2717,6 +3347,15 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" +[[package]] +name = "wasip2" +version = "1.0.1+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +dependencies = [ + "wit-bindgen", +] + [[package]] name = "wasm-bindgen" version = "0.2.100" @@ -2858,12 +3497,31 @@ dependencies = [ "memchr", ] +[[package]] +name = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "zap" -version = "0.1.0" +version = "0.2.0" dependencies = [ "anchor-lang", "anchor-spl", + "bytemuck", + "cp-amm", + "dlmm", + "ruint", ] [[package]] diff --git a/README.md b/README.md index b097a7a..01b98cf 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,10 @@ The Zap program provide util functions that allow user to zap in/out from any Am ## Zap out -User can withdraw liquidity or claim fees from Meteora pools immediately swaps the withdrawn tokens through direct pools (Damm V2 or DLMM) or Jupiter. +User can withdraw liquidity or claim fees from AMM pools and immediately swaps the withdrawn tokens through direct pools (Damm V2 or DLMM) or Jupiter. -## Zap in +## Zap in (Please refer examples in ZAPIN.md) -### TODO - Swap and deposit in Damm V2 - Swap and deposit in DLMM @@ -16,9 +15,9 @@ User can withdraw liquidity or claim fees from Meteora pools immediately swaps t ### Dependencies -- anchor 0.31.0 +- anchor 0.31.1 - solana 2.1.0 -- rust 1.79.0 +- rust 1.85.0 diff --git a/ZAPIN.md b/ZAPIN.md new file mode 100644 index 0000000..8f34242 --- /dev/null +++ b/ZAPIN.md @@ -0,0 +1,38 @@ +## Examples to zap_in damm v2 + +1. User has 1 SOL, and want to add liquidity in pool SOL-USDC, then they will send a batch of transactions (can use jito): +- Swap 0.5 SOL to USDC in JUP or directly through AMMs +- Call endpoint `initialize_ledger_account` to create a ledger account +- Set balance for token a (SOL) to 0.5 SOL in ledger account through endpoint `set_ledger_balance` +- Set balance for token b (USDC) through endpoint `update_ledger_balance_after_swap`, it will take output USDC from step 1 +- Call `zap_in_damm_v2` to add liquidity in damm v2 +- Close ledger account through endpoint `close_ledger_account` + +2. User has 1 SOL, and want to add liquidity in pool MET-USDC, then they will send a batch of transactions (can use jito): +- Swap 0.5 SOL to MET in JUP or directly through AMMs +- Swap 0.5 SOL to USDC in JUP or directly through AMMs +- Call endpoint `initialize_ledger_account` to create a ledger account +- Set balance for token a (MET) through endpoint `update_ledger_balance_after_swap`, it will take output MET from step 1 +- Set balance for token b (USDC) through endpoint `update_ledger_balance_after_swap`, it will take output USDC from step 2 +- Call `zap_in_damm_v2` to add liquidity in damm v2 +- Close ledger account through endpoint `close_ledger_account` + + +## Examples to zap_in DLMM + +1. User has 1 SOL, and want to add liquidity in pool SOL-USDC, then they will send a batch of transactions (can use jito): +- Swap 0.5 SOL to USDC in JUP or directly through AMMs +- Call endpoint `initialize_ledger_account` to create a ledger account +- Set balance for token x (SOL) to 0.5 SOL in ledger account through endpoint `set_ledger_balance` +- Set balance for token y (USDC) through endpoint `update_ledger_balance_after_swap`, it will take output USDC from step 1 +- Call `zap_in_dlmm_for_uninitialized_position`, that will create position and add liquidity to that position +- Close ledger account through endpoint `close_ledger_account` + +2. User has a position (SOL-USDC) that is out of range and they want to rebalance the position to concenstrate around pool price, they they will send a batch of transactions: +- Withdraw 100% position, +- Call endpoint `zap_out` to swap half of SOL to USDC +- Call endpoint `initialize_ledger_account` to create a ledger account +- Set balance for token x (SOL) through endpoint `update_ledger_balance_after_swap`, delta of SOL changed in user token balance +- Set balance for token y (USDC) through endpoint `update_ledger_balance_after_swap`, delta of USDC changed in user token balance +- Call `zap_in_dlmm_for_initialized_position`, that will rebalance position with the new balances +- Close ledger account through endpoint `close_ledger_account` \ No newline at end of file diff --git a/fixtures/8Pm2kZpnxD3hoMmt4bjStX2Pw2Z9abpbHzZxMPqxPmie.bin b/fixtures/8Pm2kZpnxD3hoMmt4bjStX2Pw2Z9abpbHzZxMPqxPmie.bin new file mode 100644 index 0000000..7fe2669 Binary files /dev/null and b/fixtures/8Pm2kZpnxD3hoMmt4bjStX2Pw2Z9abpbHzZxMPqxPmie.bin differ diff --git a/idls/damm_v2.json b/idls/damm_v2.json index b381c38..a7bf2f7 100644 --- a/idls/damm_v2.json +++ b/idls/damm_v2.json @@ -1,6874 +1,7436 @@ { - "address": "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG", - "metadata": { - "name": "cp_amm", - "version": "0.1.2", - "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" + "address": "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG", + "metadata": { + "name": "cp_amm", + "version": "0.1.5", + "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": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" + } + }, + { + "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": "position_nft_account", - "docs": [ - "The token account for nft" + } + }, + { + "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": "owner", - "docs": [ - "owner of position" + } + }, + { + "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" + } ], - "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 - ] - } + "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": "program" } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "AddLiquidityParameters" + }, + { + "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" } - } - } - ] - }, - { - "name": "claim_partner_fee", - "discriminator": [ - 97, - 206, - 39, - 105, - 94, - 94, - 126, - 148 - ], - "accounts": [ - { - "name": "pool_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "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 - ] - } + "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": "program" } - ], - "args": [ - { - "name": "max_amount_a", - "type": "u64" - }, - { - "name": "max_amount_b", - "type": "u64" + }, + { + "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": "claim_position_fee", - "discriminator": [ - 180, - 38, - 154, - 17, - 133, - 33, - 162, - 211 - ], - "accounts": [ - { - "name": "pool_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "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": "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": "token_a_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" + } + }, + { + "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": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" + } + }, + { + "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": "position_nft_account", - "docs": [ - "The token account for nft" + } + }, + { + "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": "owner", - "docs": [ - "owner of position" - ], - "signer": true - }, - { - "name": "token_a_program", - "docs": [ - "Token a program" + } + }, + { + "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": "token_b_program", - "docs": [ - "Token b program" + } + }, + { + "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": "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", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "pool", - "writable": true - }, - { - "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], - "writable": true, - "relations": [ - "pool" + }, + { + "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": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], - "writable": true, - "relations": [ - "pool" + } + }, + { + "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": "token_a_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" + } + }, + { + "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": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" + } + }, + { + "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": "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": { + } + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { "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 + 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": "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": { + } + } + ] + }, + { + "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": [ - 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 + 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": "claim_fee_operator", - "docs": [ - "Claim fee operator" ] - }, - { - "name": "operator", - "docs": [ - "Operator" - ], - "signer": true, - "relations": [ - "claim_fee_operator" + } + }, + { + "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": "token_a_program", - "docs": [ - "Token a program" + } + }, + { + "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": "token_b_program", - "docs": [ - "Token b program" + } + }, + { + "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": "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": "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": "claim_reward", - "discriminator": [ - 149, - 95, - 181, - 242, - 94, - 90, - 158, - 162 - ], - "accounts": [ - { - "name": "pool_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "pool", - "writable": true, - "relations": [ - "position" + }, + { + "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": "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": "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": "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": "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": "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" + }, + { + "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" + } + ] } - ], - "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" + }, + { + "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" + } + ] } - ], - "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": "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": "position", - "writable": true - }, - { - "name": "pool_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "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": "params", + "type": { + "defined": { + "name": "InitializeCustomizablePoolParameters" } - }, - { - "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" + } + ] + }, + { + "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" + } + ] } - ], - "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" + }, + { + "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" + } + ] } - ], - "args": [ - { - "name": "index", - "type": "u64" - }, - { - "name": "config_parameters", - "type": { - "defined": { - "name": "StaticConfigParameters" + }, + { + "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": "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" + }, + { + "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" + } + ] } - ], - "args": [ - { - "name": "index", - "type": "u64" - }, - { - "name": "config_parameters", - "type": { - "defined": { - "name": "DynamicConfigParameters" + }, + { + "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": "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", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "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": "params", + "type": { + "defined": { + "name": "InitializePoolParameters" } - }, - { - "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" + } + ] + }, + { + "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" + } + ] } - ], - "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" + }, + { + "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" + } + ] } - ], - "args": [ - { - "name": "reward_index", - "type": "u8" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "carry_forward", - "type": "bool" + }, + { + "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": "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", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "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_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": "token_b_mint", - "docs": [ - "Token b mint" + } + }, + { + "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": "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": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "InitializeCustomizablePoolParameters" } - }, - { - "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": "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": "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": "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": "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": "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": "pool_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "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": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "VestingParameters" } - }, - { - "name": "token_a_mint", - "docs": [ - "Token a mint" - ] - }, - { - "name": "token_b_mint", - "docs": [ - "Token b mint" + } + } + ] + }, + { + "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": "token_a_vault", + } + }, + { + "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": "split_position2", + "discriminator": [ + 221, + 147, + 228, + 207, + 140, + 212, + 17, + 119 + ], + "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": "numerator", + "type": "u32" + } + ] + }, + { + "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": "swap2", + "discriminator": [ + 65, + 75, + 63, + 76, + 235, + 91, + 91, + 136 + ], + "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": "SwapParameters2" + } + } + } + ] + }, + { + "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": "EvtLiquidityChange", + "discriminator": [ + 197, + 171, + 78, + 127, + 224, + 211, + 87, + 13 + ] + }, + { + "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": "EvtSplitPosition2", + "discriminator": [ + 165, + 32, + 203, + 174, + 72, + 100, + 233, + 103 + ] + }, + { + "name": "EvtSwap", + "discriminator": [ + 27, + 60, + 21, + 213, + 138, + 170, + 187, + 147 + ] + }, + { + "name": "EvtSwap2", + "discriminator": [ + 189, + 66, + 51, + 168, + 38, + 80, + 117, + 153 + ] + }, + { + "name": "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" + }, + { + "code": 6047, + "name": "InvalidBaseFeeMode", + "msg": "Invalid base fee mode" + }, + { + "code": 6048, + "name": "InvalidFeeRateLimiter", + "msg": "Invalid fee rate limiter" + }, + { + "code": 6049, + "name": "FailToValidateSingleSwapInstruction", + "msg": "Fail to validate single swap instruction in rate limiter" + }, + { + "code": 6050, + "name": "InvalidFeeScheduler", + "msg": "Invalid fee scheduler" + }, + { + "code": 6051, + "name": "UndeterminedError", + "msg": "Undetermined error" + }, + { + "code": 6052, + "name": "InvalidPoolVersion", + "msg": "Invalid pool version" + } + ], + "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": "base_fee_mode", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 5 + ] + } + }, + { + "name": "first_factor", + "type": "u16" + }, + { + "name": "second_factor", + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "third_factor", + "type": "u64" + } + ] + } + }, + { + "name": "BaseFeeParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "cliff_fee_numerator", + "type": "u64" + }, + { + "name": "first_factor", + "type": "u16" + }, + { + "name": "second_factor", + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "third_factor", + "type": "u64" + }, + { + "name": "base_fee_mode", + "type": "u8" + } + ] + } + }, + { + "name": "BaseFeeStruct", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "cliff_fee_numerator", + "type": "u64" + }, + { + "name": "base_fee_mode", + "type": "u8" + }, + { + "name": "padding_0", + "type": { + "array": [ + "u8", + 5 + ] + } + }, + { + "name": "first_factor", + "type": "u16" + }, + { + "name": "second_factor", + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "third_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": [ - "Token a vault for the pool" + "Config pubkey" ], - "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" - } - ] - } + "type": "pubkey" }, { - "name": "token_b_vault", + "name": "admin", "docs": [ - "Token b vault for the pool" + "admin pk" ], - "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" - } - ] + "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": "payer_token_a", - "docs": [ - "payer token a account" - ], - "writable": true + "name": "vault_config_key", + "type": "pubkey" }, { - "name": "payer_token_b", - "docs": [ - "creator token b account" - ], - "writable": true + "name": "pool_creator_authority", + "type": "pubkey" }, { - "name": "token_a_program", - "docs": [ - "Program to create mint account and mint tokens" - ] + "name": "activation_type", + "type": "u8" }, { - "name": "token_b_program", - "docs": [ - "Program to create mint account and mint tokens" - ] + "name": "sqrt_min_price", + "type": "u128" }, { - "name": "token_2022_program", - "docs": [ - "Program to create NFT mint/token account and transfer for token22 account" - ], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + "name": "sqrt_max_price", + "type": "u128" }, { - "name": "system_program", - "address": "11111111111111111111111111111111" + "name": "collect_fee_mode", + "type": "u8" }, { - "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": "index", + "type": "u64" }, { - "name": "program" + "name": "config", + "type": "pubkey" } - ], - "args": [ + ] + } + }, + { + "name": "EvtCreateDynamicConfig", + "docs": [ + "Create dynamic config" + ], + "type": { + "kind": "struct", + "fields": [ { - "name": "params", + "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": "InitializePoolParameters" + "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": "initialize_pool_with_dynamic_config", - "discriminator": [ - 149, - 82, - 72, - 197, - 253, - 252, - 68, - 15 - ], - "accounts": [ - { - "name": "creator" + } + }, + { + "name": "EvtInitializeReward", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" }, { - "name": "position_nft_mint", - "docs": [ - "position_nft_mint" - ], - "writable": true, - "signer": true + "name": "reward_mint", + "type": "pubkey" + }, + { + "name": "funder", + "type": "pubkey" + }, + { + "name": "creator", + "type": "pubkey" + }, + { + "name": "reward_index", + "type": "u8" + }, + { + "name": "reward_duration", + "type": "u64" + } + ] + } + }, + { + "name": "EvtLiquidityChange", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pool", + "type": "pubkey" + }, + { + "name": "position", + "type": "pubkey" }, { - "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": "owner", + "type": "pubkey" }, { - "name": "payer", - "docs": [ - "Address paying to create the pool. Can be anyone" - ], - "writable": true, - "signer": true + "name": "token_a_amount", + "type": "u64" }, { - "name": "pool_creator_authority", - "signer": true, - "relations": [ - "config" - ] + "name": "token_b_amount", + "type": "u64" }, { - "name": "config", - "docs": [ - "Which config the pool belongs to." - ] + "name": "transfer_fee_included_token_a_amount", + "type": "u64" }, { - "name": "pool_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } + "name": "transfer_fee_included_token_b_amount", + "type": "u64" }, { - "name": "pool", - "docs": [ - "Initialize an account to store the pool state" - ], - "writable": true + "name": "reserve_a_amount", + "type": "u64" }, { - "name": "position", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 115, - 105, - 116, - 105, - 111, - 110 - ] - }, - { - "kind": "account", - "path": "position_nft_mint" - } - ] - } + "name": "reserve_b_amount", + "type": "u64" }, { - "name": "token_a_mint", - "docs": [ - "Token a mint" - ] + "name": "liquidity_delta", + "type": "u128" }, { - "name": "token_b_mint", - "docs": [ - "Token b mint" - ] + "name": "token_a_amount_threshold", + "type": "u64" }, { - "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_amount_threshold", + "type": "u64" }, { - "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": "change_type", + "type": "u8" + } + ] + } + }, + { + "name": "EvtLockPosition", + "type": { + "kind": "struct", + "fields": [ { - "name": "payer_token_a", - "docs": [ - "payer token a account" - ], - "writable": true + "name": "pool", + "type": "pubkey" }, { - "name": "payer_token_b", - "docs": [ - "creator token b account" - ], - "writable": true + "name": "position", + "type": "pubkey" }, { - "name": "token_a_program", - "docs": [ - "Program to create mint account and mint tokens" - ] + "name": "owner", + "type": "pubkey" }, { - "name": "token_b_program", - "docs": [ - "Program to create mint account and mint tokens" - ] + "name": "vesting", + "type": "pubkey" }, { - "name": "token_2022_program", - "docs": [ - "Program to create NFT mint/token account and transfer for token22 account" - ], - "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + "name": "cliff_point", + "type": "u64" }, { - "name": "system_program", - "address": "11111111111111111111111111111111" + "name": "period_frequency", + "type": "u64" }, { - "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": "cliff_unlock_liquidity", + "type": "u128" }, { - "name": "program" - } - ], - "args": [ + "name": "liquidity_per_period", + "type": "u128" + }, { - "name": "params", - "type": { - "defined": { - "name": "InitializeCustomizablePoolParameters" - } - } + "name": "number_of_period", + "type": "u16" } ] - }, - { - "name": "initialize_reward", - "discriminator": [ - 95, - 135, - 192, - 196, - 242, - 129, - 230, - 68 - ], - "accounts": [ - { - "name": "pool_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, + } + }, + { + "name": "EvtPermanentLockPosition", + "type": { + "kind": "struct", + "fields": [ { "name": "pool", - "writable": true + "type": "pubkey" }, { - "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": "position", + "type": "pubkey" }, { - "name": "reward_mint" + "name": "lock_liquidity_amount", + "type": "u128" }, { - "name": "signer", - "signer": true - }, + "name": "total_permanent_locked_liquidity", + "type": "u128" + } + ] + } + }, + { + "name": "EvtRemoveLiquidity", + "type": { + "kind": "struct", + "fields": [ { - "name": "payer", - "writable": true, - "signer": true + "name": "pool", + "type": "pubkey" }, { - "name": "token_program" + "name": "position", + "type": "pubkey" }, { - "name": "system_program", - "address": "11111111111111111111111111111111" + "name": "owner", + "type": "pubkey" }, { - "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": "params", + "type": { + "defined": { + "name": "RemoveLiquidityParameters" + } } }, { - "name": "program" - } - ], - "args": [ - { - "name": "reward_index", - "type": "u8" + "name": "token_a_amount", + "type": "u64" }, { - "name": "reward_duration", + "name": "token_b_amount", "type": "u64" - }, + } + ] + } + }, + { + "name": "EvtSetPoolStatus", + "type": { + "kind": "struct", + "fields": [ { - "name": "funder", + "name": "pool", "type": "pubkey" + }, + { + "name": "status", + "type": "u8" } ] - }, - { - "name": "lock_position", - "discriminator": [ - 227, - 62, - 2, - 252, - 247, - 10, - 171, - 185 - ], - "accounts": [ + } + }, + { + "name": "EvtSplitPosition2", + "type": { + "kind": "struct", + "fields": [ { "name": "pool", - "relations": [ - "position" - ] + "type": "pubkey" }, { - "name": "position", - "writable": true + "name": "first_owner", + "type": "pubkey" }, { - "name": "vesting", - "writable": true, - "signer": true + "name": "second_owner", + "type": "pubkey" }, { - "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] + "name": "first_position", + "type": "pubkey" }, { - "name": "owner", - "docs": [ - "owner of position" - ], - "signer": true + "name": "second_position", + "type": "pubkey" }, { - "name": "payer", - "writable": true, - "signer": true + "name": "current_sqrt_price", + "type": "u128" }, { - "name": "system_program", - "address": "11111111111111111111111111111111" + "name": "amount_splits", + "type": { + "defined": { + "name": "SplitAmountInfo" + } + } }, { - "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": "first_position_info", + "type": { + "defined": { + "name": "SplitPositionInfo" + } } }, { - "name": "program" - } - ], - "args": [ + "name": "second_position_info", + "type": { + "defined": { + "name": "SplitPositionInfo" + } + } + }, { - "name": "params", + "name": "split_position_parameters", "type": { "defined": { - "name": "VestingParameters" + "name": "SplitPositionParameters2" } } } ] - }, - { - "name": "permanent_lock_position", - "discriminator": [ - 165, - 176, - 125, - 6, - 231, - 171, - 186, - 213 - ], - "accounts": [ + } + }, + { + "name": "EvtSwap", + "type": { + "kind": "struct", + "fields": [ { "name": "pool", - "writable": true, - "relations": [ - "position" - ] + "type": "pubkey" }, { - "name": "position", - "writable": true + "name": "trade_direction", + "type": "u8" }, { - "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] + "name": "has_referral", + "type": "bool" }, { - "name": "owner", - "docs": [ - "owner of position" - ], - "signer": true + "name": "params", + "type": { + "defined": { + "name": "SwapParameters" + } + } }, { - "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": "swap_result", + "type": { + "defined": { + "name": "SwapResult" + } } }, { - "name": "program" - } - ], - "args": [ + "name": "actual_amount_in", + "type": "u64" + }, { - "name": "permanent_lock_liquidity", - "type": "u128" + "name": "current_timestamp", + "type": "u64" } ] - }, - { - "name": "refresh_vesting", - "discriminator": [ - 9, - 94, - 216, - 14, - 116, - 204, - 247, - 0 - ], - "accounts": [ + } + }, + { + "name": "EvtSwap2", + "type": { + "kind": "struct", + "fields": [ { "name": "pool", - "relations": [ - "position" - ] + "type": "pubkey" }, { - "name": "position", - "writable": true + "name": "trade_direction", + "type": "u8" }, { - "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] + "name": "collect_fee_mode", + "type": "u8" }, { - "name": "owner" - } - ], - "args": [] - }, - { - "name": "remove_all_liquidity", - "discriminator": [ - 10, - 51, - 61, - 35, - 112, - 105, - 24, - 85 - ], - "accounts": [ - { - "name": "pool_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] + "name": "has_referral", + "type": "bool" + }, + { + "name": "params", + "type": { + "defined": { + "name": "SwapParameters2" + } } }, { - "name": "pool", - "writable": true, - "relations": [ - "position" - ] + "name": "swap_result", + "type": { + "defined": { + "name": "SwapResult2" + } + } }, { - "name": "position", - "writable": true + "name": "included_transfer_fee_amount_in", + "type": "u64" }, { - "name": "token_a_account", - "docs": [ - "The user token a account" - ], - "writable": true + "name": "included_transfer_fee_amount_out", + "type": "u64" }, { - "name": "token_b_account", - "docs": [ - "The user token b account" - ], - "writable": true + "name": "excluded_transfer_fee_amount_out", + "type": "u64" }, { - "name": "token_a_vault", - "docs": [ - "The vault token account for input token" - ], - "writable": true, - "relations": [ - "pool" - ] + "name": "current_timestamp", + "type": "u64" }, { - "name": "token_b_vault", - "docs": [ - "The vault token account for output token" - ], - "writable": true, - "relations": [ - "pool" - ] + "name": "reserve_a_amount", + "type": "u64" }, { - "name": "token_a_mint", - "docs": [ - "The mint of token a" - ], - "relations": [ - "pool" - ] - }, + "name": "reserve_b_amount", + "type": "u64" + } + ] + } + }, + { + "name": "EvtUpdateRewardDuration", + "type": { + "kind": "struct", + "fields": [ { - "name": "token_b_mint", - "docs": [ - "The mint of token b" - ], - "relations": [ - "pool" - ] + "name": "pool", + "type": "pubkey" }, { - "name": "position_nft_account", - "docs": [ - "The token account for nft" - ] + "name": "reward_index", + "type": "u8" }, { - "name": "owner", - "docs": [ - "owner of position" - ], - "signer": true + "name": "old_reward_duration", + "type": "u64" }, { - "name": "token_a_program", - "docs": [ - "Token a program" - ] - }, + "name": "new_reward_duration", + "type": "u64" + } + ] + } + }, + { + "name": "EvtUpdateRewardFunder", + "type": { + "kind": "struct", + "fields": [ { - "name": "token_b_program", - "docs": [ - "Token b program" - ] + "name": "pool", + "type": "pubkey" }, { - "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": "reward_index", + "type": "u8" }, { - "name": "program" - } - ], - "args": [ - { - "name": "token_a_amount_threshold", - "type": "u64" + "name": "old_funder", + "type": "pubkey" }, { - "name": "token_b_amount_threshold", - "type": "u64" + "name": "new_funder", + "type": "pubkey" } ] - }, - { - "name": "remove_liquidity", - "discriminator": [ - 80, - 85, - 209, - 72, - 24, - 206, - 177, - 108 - ], - "accounts": [ - { - "name": "pool_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, + } + }, + { + "name": "EvtWithdrawIneligibleReward", + "type": { + "kind": "struct", + "fields": [ { "name": "pool", - "writable": true, - "relations": [ - "position" - ] + "type": "pubkey" }, { - "name": "position", - "writable": true + "name": "reward_mint", + "type": "pubkey" }, { - "name": "token_a_account", - "docs": [ - "The user token a account" - ], - "writable": true - }, + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "InitializeCustomizablePoolParameters", + "type": { + "kind": "struct", + "fields": [ { - "name": "token_b_account", + "name": "pool_fees", "docs": [ - "The user token b account" + "pool fees" ], - "writable": true + "type": { + "defined": { + "name": "PoolFeeParameters" + } + } }, { - "name": "token_a_vault", + "name": "sqrt_min_price", "docs": [ - "The vault token account for input token" + "sqrt min price" ], - "writable": true, - "relations": [ - "pool" - ] + "type": "u128" }, { - "name": "token_b_vault", + "name": "sqrt_max_price", "docs": [ - "The vault token account for output token" + "sqrt max price" ], - "writable": true, - "relations": [ - "pool" - ] + "type": "u128" }, { - "name": "token_a_mint", + "name": "has_alpha_vault", "docs": [ - "The mint of token a" + "has alpha vault" ], - "relations": [ - "pool" - ] + "type": "bool" }, { - "name": "token_b_mint", + "name": "liquidity", "docs": [ - "The mint of token b" + "initialize liquidity" ], - "relations": [ - "pool" - ] + "type": "u128" }, { - "name": "position_nft_account", + "name": "sqrt_price", "docs": [ - "The token account for nft" - ] + "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value" + ], + "type": "u128" }, { - "name": "owner", + "name": "activation_type", "docs": [ - "owner of position" + "activation type" ], - "signer": true + "type": "u8" }, { - "name": "token_a_program", + "name": "collect_fee_mode", "docs": [ - "Token a program" - ] + "collect fee mode" + ], + "type": "u8" }, { - "name": "token_b_program", + "name": "activation_point", "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", + "activation point" + ], "type": { - "defined": { - "name": "RemoveLiquidityParameters" - } + "option": "u64" } } ] - }, - { - "name": "set_pool_status", - "discriminator": [ - 112, - 87, - 135, - 223, - 83, - 204, - 132, - 53 - ], - "accounts": [ + } + }, + { + "name": "InitializePoolParameters", + "type": { + "kind": "struct", + "fields": [ { - "name": "pool", - "writable": true + "name": "liquidity", + "docs": [ + "initialize liquidity" + ], + "type": "u128" }, { - "name": "admin", - "signer": true + "name": "sqrt_price", + "docs": [ + "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value" + ], + "type": "u128" }, { - "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": "activation_point", + "docs": [ + "activation point" + ], + "type": { + "option": "u64" } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "status", - "type": "u8" } ] + } + }, + { + "name": "Pool", + "serialization": "bytemuck", + "repr": { + "kind": "c" }, - { - "name": "swap", - "discriminator": [ - 248, - 198, - 158, - 145, - 225, - 117, - 135, - 200 - ], - "accounts": [ - { - "name": "pool_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, + "type": { + "kind": "struct", + "fields": [ { - "name": "pool", + "name": "pool_fees", "docs": [ - "Pool account" + "Pool fee" ], - "writable": true + "type": { + "defined": { + "name": "PoolFeesStruct" + } + } }, { - "name": "input_token_account", + "name": "token_a_mint", "docs": [ - "The user token account for input token" + "token a mint" ], - "writable": true + "type": "pubkey" }, { - "name": "output_token_account", + "name": "token_b_mint", "docs": [ - "The user token account for output token" + "token b mint" ], - "writable": true + "type": "pubkey" }, { "name": "token_a_vault", "docs": [ - "The vault token account for input token" + "token a vault" ], - "writable": true, - "relations": [ - "pool" - ] + "type": "pubkey" }, { "name": "token_b_vault", "docs": [ - "The vault token account for output token" + "token b vault" ], - "writable": true, - "relations": [ - "pool" - ] + "type": "pubkey" }, { - "name": "token_a_mint", + "name": "whitelisted_vault", "docs": [ - "The mint of token a" - ] + "Whitelisted vault to be able to buy pool before activation_point" + ], + "type": "pubkey" }, { - "name": "token_b_mint", + "name": "partner", "docs": [ - "The mint of token b" - ] + "partner" + ], + "type": "pubkey" }, { - "name": "payer", + "name": "liquidity", "docs": [ - "The user performing the swap" + "liquidity share" ], - "signer": true + "type": "u128" }, { - "name": "token_a_program", + "name": "_padding", "docs": [ - "Token a program" - ] + "padding, previous reserve amount, be careful to use that field" + ], + "type": "u128" }, { - "name": "token_b_program", + "name": "protocol_a_fee", "docs": [ - "Token b program" - ] + "protocol a fee" + ], + "type": "u64" }, { - "name": "referral_token_account", + "name": "protocol_b_fee", "docs": [ - "referral token account" + "protocol b fee" ], - "writable": true, - "optional": true + "type": "u64" }, { - "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": "partner_a_fee", + "docs": [ + "partner a fee" + ], + "type": "u64" }, { - "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": "partner_b_fee", + "docs": [ + "partner b fee" + ], + "type": "u64" }, { - "name": "signer", - "signer": true + "name": "sqrt_min_price", + "docs": [ + "min price" + ], + "type": "u128" }, { - "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": "sqrt_max_price", + "docs": [ + "max price" + ], + "type": "u128" }, { - "name": "program" - } - ], - "args": [ - { - "name": "reward_index", - "type": "u8" + "name": "sqrt_price", + "docs": [ + "current price" + ], + "type": "u128" }, { - "name": "new_duration", + "name": "activation_point", + "docs": [ + "Activation point, can be slot or timestamp" + ], "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": "activation_type", + "docs": [ + "Activation type, 0 means by slot, 1 means by timestamp" + ], + "type": "u8" }, { - "name": "program" - } - ], - "args": [ - { - "name": "reward_index", + "name": "pool_status", + "docs": [ + "pool status, 0: enable, 1 disable" + ], "type": "u8" }, { - "name": "new_funder", - "type": "pubkey" - } - ] - }, - { - "name": "withdraw_ineligible_reward", - "discriminator": [ - 148, - 206, - 42, - 195, - 247, - 49, - 103, - 8 - ], - "accounts": [ - { - "name": "pool_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } + "name": "token_a_flag", + "docs": [ + "token a flag" + ], + "type": "u8" }, { - "name": "pool", - "writable": true + "name": "token_b_flag", + "docs": [ + "token b flag" + ], + "type": "u8" }, { - "name": "reward_vault", - "writable": true + "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": "reward_mint" + "name": "pool_type", + "docs": [ + "pool type" + ], + "type": "u8" }, { - "name": "funder_token_account", - "writable": true + "name": "version", + "docs": [ + "pool version, 0: max_fee is still capped at 50%, 1: max_fee is capped at 99%" + ], + "type": "u8" }, { - "name": "funder", - "signer": true + "name": "_padding_0", + "docs": [ + "padding" + ], + "type": "u8" }, { - "name": "token_program" + "name": "fee_a_per_liquidity", + "docs": [ + "cumulative" + ], + "type": { + "array": [ + "u8", + 32 + ] + } }, { - "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": "fee_b_per_liquidity", + "docs": [ + "cumulative" + ], + "type": { + "array": [ + "u8", + 32 ] } }, { - "name": "program" - } - ], - "args": [ + "name": "permanent_lock_liquidity", + "type": "u128" + }, { - "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": "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" - } - ], - "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": "metrics", + "docs": [ + "metrics" + ], + "type": { + "defined": { + "name": "PoolMetrics" } - }, - { - "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": "creator", + "docs": [ + "pool creator" + ], + "type": "pubkey" + }, + { + "name": "_padding_1", + "docs": [ + "Padding for further use" + ], + "type": { + "array": [ + "u64", + 6 + ] } - ] - } - }, - { - "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": "reward_infos", + "docs": [ + "Farming reward information" + ], + "type": { + "array": [ + { + "defined": { + "name": "RewardInfo" + } + }, + 2 + ] } - ] - } - }, - { - "name": "EvtCreateTokenBadge", - "docs": [ - "Create token badge" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "token_mint", - "type": "pubkey" + } + ] + } + }, + { + "name": "PoolFeeParameters", + "docs": [ + "Information regarding fee charges" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "base_fee", + "docs": [ + "Base fee" + ], + "type": { + "defined": { + "name": "BaseFeeParameters" + } } - ] - } - }, - { - "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": "padding", + "docs": [ + "padding" + ], + "type": { + "array": [ + "u8", + 3 + ] } - ] - } - }, - { - "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": { + }, + { + "name": "dynamic_fee", + "docs": [ + "dynamic fee" + ], + "type": { + "option": { "defined": { - "name": "PoolFeeParameters" + "name": "DynamicFeeParameters" } } - }, - { - "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": "PoolFeesConfig", + "serialization": "bytemuck", + "repr": { + "kind": "c" }, - { - "name": "EvtInitializeReward", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "reward_mint", - "type": "pubkey" - }, - { - "name": "funder", - "type": "pubkey" - }, - { - "name": "reward_index", - "type": "u8" - }, - { - "name": "reward_duration", - "type": "u64" + "type": { + "kind": "struct", + "fields": [ + { + "name": "base_fee", + "type": { + "defined": { + "name": "BaseFeeConfig" + } } - ] - } - }, - { - "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": "dynamic_fee", + "type": { + "defined": { + "name": "DynamicFeeConfig" + } } - ] - } - }, - { - "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": "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": "EvtRemoveLiquidity", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "params", - "type": { - "defined": { - "name": "RemoveLiquidityParameters" - } + }, + { + "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": "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": "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": "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": "dynamic_fee", + "docs": [ + "dynamic fee" + ], + "type": { + "defined": { + "name": "DynamicFeeStruct" } - }, - { - "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": "padding_1", + "docs": [ + "padding" + ], + "type": { + "array": [ + "u64", + 2 + ] } - ] - } + } + ] + } + }, + { + "name": "PoolMetrics", + "serialization": "bytemuck", + "repr": { + "kind": "c" }, - { - "name": "EvtWithdrawIneligibleReward", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pool", - "type": "pubkey" - }, - { - "name": "reward_mint", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - } - ] - } + "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" }, - { - "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" - } + "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": "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": "fee_b_per_token_checkpoint", + "docs": [ + "fee b checkpoint" + ], + "type": { + "array": [ + "u8", + 32 + ] } - ] - } - }, - { - "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": "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": "PoolFeeParameters", - "docs": [ - "Information regarding fee charges" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "base_fee", - "docs": [ - "Base fee" - ], - "type": { - "defined": { - "name": "BaseFeeParameters" - } - } - }, - { - "name": "protocol_fee_percent", - "docs": [ - "Protocol trade fee percent" - ], - "type": "u8" - }, - { - "name": "partner_fee_percent", - "docs": [ - "partner fee percent" - ], - "type": "u8" - }, - { - "name": "referral_fee_percent", - "docs": [ - "referral fee percent" - ], - "type": "u8" - }, - { - "name": "dynamic_fee", - "docs": [ - "dynamic fee" - ], - "type": { - "option": { + }, + { + "name": "reward_infos", + "docs": [ + "Farming reward information" + ], + "type": { + "array": [ + { "defined": { - "name": "DynamicFeeParameters" + "name": "UserRewardInfo" } - } - } - } - ] - } - }, - { - "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 - ] - } + }, + 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": "padding", + "docs": [ + "padding for future usage" + ], + "type": { + "array": [ + "u128", + 6 + ] } - ] - } + } + ] + } + }, + { + "name": "PositionMetrics", + "serialization": "bytemuck", + "repr": { + "kind": "c" }, - { - "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 - ] - } + "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": "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": "_padding_1", + "docs": [ + "Padding to ensure `reward_rate: u128` is 16-byte aligned" + ], + "type": { + "array": [ + "u8", + 8 + ] } - ] - } - }, - { - "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": "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": "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": "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": "SplitPositionParameters2", + "type": { + "kind": "struct", + "fields": [ + { + "name": "unlocked_liquidity_numerator", + "type": "u32" + }, + { + "name": "permanent_locked_liquidity_numerator", + "type": "u32" + }, + { + "name": "fee_a_numerator", + "type": "u32" + }, + { + "name": "fee_b_numerator", + "type": "u32" + }, + { + "name": "reward_0_numerator", + "type": "u32" + }, + { + "name": "reward_1_numerator", + "type": "u32" + } + ] + } + }, + { + "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": "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": "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": "output_amount", + "type": "u64" + }, + { + "name": "next_sqrt_price", + "type": "u128" + }, + { + "name": "lp_fee", + "type": "u64" + }, + { + "name": "protocol_fee", + "type": "u64" + }, + { + "name": "partner_fee", + "type": "u64" + }, + { + "name": "referral_fee", + "type": "u64" + } + ] + } + }, + { + "name": "SwapResult2", + "type": { + "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": "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" }, - { - "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 - ] - } + "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" }, - { - "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" + "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": "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": "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" + } + ] + } + }, + { + "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 + } + ] +} \ No newline at end of file diff --git a/idls/dlmm.json b/idls/dlmm.json index 0cc16a3..d53eb87 100644 --- a/idls/dlmm.json +++ b/idls/dlmm.json @@ -2,69 +2,125 @@ "address": "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo", "metadata": { "name": "lb_clmm", - "version": "0.9.1", - "spec": "0.1.0" + "version": "0.10.1", + "spec": "0.1.0", + "description": "Created with Anchor" }, "instructions": [ { - "name": "initialize_lb_pair", + "name": "add_liquidity", "discriminator": [ - 45, - 154, - 237, - 210, - 221, - 15, - 166, - 92 + 181, + 157, + 89, + 67, + 143, + 182, + 52, + 72 ], "accounts": [ { - "name": "lb_pair", + "name": "position", "writable": true }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] + }, { "name": "bin_array_bitmap_extension", "writable": true, "optional": true }, { - "name": "token_mint_x" + "name": "user_token_x", + "writable": true }, { - "name": "token_mint_y" + "name": "user_token_y", + "writable": true }, { "name": "reserve_x", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { "name": "reserve_y", - "writable": true - }, - { - "name": "oracle", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "preset_parameter" + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "funder", - "writable": true, - "signer": true + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "token_program" + "name": "bin_array_lower", + "writable": true }, { - "name": "system_program" + "name": "bin_array_upper", + "writable": true }, { - "name": "rent" + "name": "sender", + "signer": true }, { - "name": "event_authority" + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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" @@ -72,35 +128,39 @@ ], "args": [ { - "name": "active_id", - "type": "i32" - }, - { - "name": "bin_step", - "type": "u16" + "name": "liquidity_parameter", + "type": { + "defined": { + "name": "LiquidityParameter" + } + } } ] }, { - "name": "initialize_permission_lb_pair", + "name": "add_liquidity2", "discriminator": [ - 108, - 102, - 213, - 85, - 251, - 3, - 53, - 21 + 228, + 162, + 78, + 28, + 70, + 219, + 116, + 115 ], "accounts": [ { - "name": "base", - "signer": true + "name": "position", + "writable": true }, { "name": "lb_pair", - "writable": true + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension" + ] }, { "name": "bin_array_bitmap_extension", @@ -108,50 +168,77 @@ "optional": true }, { - "name": "token_mint_x" - }, - { - "name": "token_mint_y" - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", + "name": "user_token_x", "writable": true }, { - "name": "oracle", + "name": "user_token_y", "writable": true }, { - "name": "admin", + "name": "reserve_x", "writable": true, - "signer": true + "relations": [ + "lb_pair" + ] }, { - "name": "token_badge_x", - "optional": true + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "token_badge_y", - "optional": true + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "token_program_x" + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "token_program_y" + "name": "sender", + "signer": true }, { - "name": "system_program" + "name": "token_x_program" }, { - "name": "rent" + "name": "token_y_program" }, { - "name": "event_authority" + "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" @@ -159,74 +246,137 @@ ], "args": [ { - "name": "ix_data", + "name": "liquidity_parameter", "type": { "defined": { - "name": "InitPermissionPairIx" + "name": "LiquidityParameter" + } + } + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" } } } ] }, { - "name": "initialize_customizable_permissionless_lb_pair", + "name": "add_liquidity_by_strategy", "discriminator": [ - 46, - 39, - 41, - 135, - 111, - 183, - 200, - 64 + 7, + 3, + 150, + 127, + 148, + 40, + 61, + 200 ], "accounts": [ { - "name": "lb_pair", + "name": "position", "writable": true }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] + }, { "name": "bin_array_bitmap_extension", "writable": true, "optional": true }, { - "name": "token_mint_x" + "name": "user_token_x", + "writable": true }, { - "name": "token_mint_y" + "name": "user_token_y", + "writable": true }, { "name": "reserve_x", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { "name": "reserve_y", - "writable": true - }, - { - "name": "oracle", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "user_token_x" + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "funder", - "writable": true, - "signer": true + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "token_program" + "name": "bin_array_lower", + "writable": true }, { - "name": "system_program" + "name": "bin_array_upper", + "writable": true }, { - "name": "user_token_y" + "name": "sender", + "signer": true }, { - "name": "event_authority" + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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" @@ -234,99 +384,152 @@ ], "args": [ { - "name": "params", + "name": "liquidity_parameter", "type": { "defined": { - "name": "CustomizableParams" + "name": "LiquidityParameterByStrategy" } } } ] }, { - "name": "initialize_bin_array_bitmap_extension", + "name": "add_liquidity_by_strategy2", "discriminator": [ - 47, - 157, - 226, - 180, - 12, - 240, - 33, - 71 + 3, + 221, + 149, + 218, + 111, + 141, + 118, + 213 ], "accounts": [ { - "name": "lb_pair" + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension" + ] }, { "name": "bin_array_bitmap_extension", - "docs": [ - "Initialize an account to store if a bin array is initialized." - ], + "writable": true, + "optional": true + }, + { + "name": "user_token_x", "writable": true }, { - "name": "funder", - "writable": true, - "signer": true + "name": "user_token_y", + "writable": true }, { - "name": "system_program" + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "rent" - } - ], - "args": [] - }, - { - "name": "initialize_bin_array", - "discriminator": [ - 35, - 86, - 19, - 185, - 78, - 212, - 75, - 211 - ], - "accounts": [ + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, { - "name": "lb_pair" + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "bin_array", - "writable": true + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "funder", - "writable": true, + "name": "sender", "signer": true }, { - "name": "system_program" - } - ], - "args": [ - { - "name": "index", - "type": "i64" + "name": "token_x_program" + }, + { + "name": "token_y_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": "liquidity_parameter", + "type": { + "defined": { + "name": "LiquidityParameterByStrategy" + } + } + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } + } } ] }, { - "name": "add_liquidity", + "name": "add_liquidity_by_strategy_one_side", "discriminator": [ - 181, - 157, - 89, - 67, - 143, - 182, - 52, - 72 + 41, + 5, + 238, + 175, + 100, + 225, + 6, + 205 ], "accounts": [ { @@ -335,7 +538,13 @@ }, { "name": "lb_pair", - "writable": true + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] }, { "name": "bin_array_bitmap_extension", @@ -343,26 +552,15 @@ "optional": true }, { - "name": "user_token_x", - "writable": true - }, - { - "name": "user_token_y", - "writable": true - }, - { - "name": "reserve_x", + "name": "user_token", "writable": true }, { - "name": "reserve_y", + "name": "reserve", "writable": true }, { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" + "name": "token_mint" }, { "name": "bin_array_lower", @@ -377,13 +575,37 @@ "signer": true }, { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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" @@ -394,7 +616,7 @@ "name": "liquidity_parameter", "type": { "defined": { - "name": "LiquidityParameter" + "name": "LiquidityParameterByStrategyOneSide" } } } @@ -419,7 +641,13 @@ }, { "name": "lb_pair", - "writable": true + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] }, { "name": "bin_array_bitmap_extension", @@ -436,17 +664,29 @@ }, { "name": "reserve_x", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { "name": "reserve_y", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "token_x_mint" + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "token_y_mint" + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] }, { "name": "bin_array_lower", @@ -461,13 +701,41 @@ "signer": true }, { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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" @@ -485,16 +753,16 @@ ] }, { - "name": "add_liquidity_by_strategy", + "name": "add_liquidity_one_side", "discriminator": [ - 7, - 3, - 150, - 127, - 148, - 40, - 61, - 200 + 94, + 155, + 103, + 151, + 70, + 95, + 220, + 165 ], "accounts": [ { @@ -503,7 +771,13 @@ }, { "name": "lb_pair", - "writable": true + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] }, { "name": "bin_array_bitmap_extension", @@ -511,26 +785,15 @@ "optional": true }, { - "name": "user_token_x", - "writable": true - }, - { - "name": "user_token_y", - "writable": true - }, - { - "name": "reserve_x", + "name": "user_token", "writable": true }, { - "name": "reserve_y", + "name": "reserve", "writable": true }, { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" + "name": "token_mint" }, { "name": "bin_array_lower", @@ -545,13 +808,37 @@ "signer": true }, { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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" @@ -562,23 +849,23 @@ "name": "liquidity_parameter", "type": { "defined": { - "name": "LiquidityParameterByStrategy" + "name": "LiquidityOneSideParameter" } } } ] }, { - "name": "add_liquidity_by_strategy_one_side", + "name": "add_liquidity_one_side_precise", "discriminator": [ - 41, - 5, - 238, - 175, - 100, - 225, - 6, - 205 + 161, + 194, + 103, + 84, + 171, + 71, + 250, + 154 ], "accounts": [ { @@ -587,7 +874,13 @@ }, { "name": "lb_pair", - "writable": true + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] }, { "name": "bin_array_bitmap_extension", @@ -618,10 +911,37 @@ "signer": true }, { - "name": "token_program" - }, - { - "name": "event_authority" + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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" @@ -629,26 +949,26 @@ ], "args": [ { - "name": "liquidity_parameter", + "name": "parameter", "type": { "defined": { - "name": "LiquidityParameterByStrategyOneSide" + "name": "AddLiquiditySingleSidePreciseParameter" } } } ] }, { - "name": "add_liquidity_one_side", + "name": "add_liquidity_one_side_precise2", "discriminator": [ - 94, - 155, - 103, - 151, - 70, - 95, - 220, - 165 + 33, + 51, + 163, + 201, + 117, + 98, + 125, + 231 ], "accounts": [ { @@ -657,7 +977,11 @@ }, { "name": "lb_pair", - "writable": true + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension" + ] }, { "name": "bin_array_bitmap_extension", @@ -675,14 +999,6 @@ { "name": "token_mint" }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, { "name": "sender", "signer": true @@ -691,7 +1007,33 @@ "name": "token_program" }, { - "name": "event_authority" + "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" @@ -702,136 +1044,231 @@ "name": "liquidity_parameter", "type": { "defined": { - "name": "LiquidityOneSideParameter" + "name": "AddLiquiditySingleSidePreciseParameter2" + } + } + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" } } } ] }, { - "name": "remove_liquidity", + "name": "claim_fee", "discriminator": [ - 80, - 85, - 209, - 72, - 24, - 206, - 177, - 108 + 169, + 32, + 79, + 137, + 136, + 232, + 70, + 137 ], "accounts": [ - { - "name": "position", - "writable": true - }, { "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", "writable": true, - "optional": true + "relations": [ + "position", + "bin_array_lower", + "bin_array_upper" + ] }, { - "name": "user_token_x", + "name": "position", "writable": true }, { - "name": "user_token_y", + "name": "bin_array_lower", "writable": true }, { - "name": "reserve_x", + "name": "bin_array_upper", "writable": true }, { - "name": "reserve_y", - "writable": true + "name": "sender", + "signer": true }, { - "name": "token_x_mint" + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "token_y_mint" + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "bin_array_lower", + "name": "user_token_x", "writable": true }, { - "name": "bin_array_upper", + "name": "user_token_y", "writable": true }, { - "name": "sender", - "signer": true - }, - { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "bin_liquidity_removal", - "type": { - "vec": { - "defined": { - "name": "BinLiquidityReduction" - } - } - } - } - ] + "args": [] }, { - "name": "initialize_position", + "name": "claim_fee2", "discriminator": [ - 219, - 192, - 234, - 71, - 190, + 112, 191, - 102, - 80 + 101, + 171, + 28, + 144, + 127, + 187 ], "accounts": [ { - "name": "payer", + "name": "lb_pair", "writable": true, - "signer": true + "relations": [ + "position" + ] }, { "name": "position", - "writable": true, + "writable": true + }, + { + "name": "sender", "signer": true }, { - "name": "lb_pair" + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "owner", - "signer": true + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "user_token_x", + "writable": true + }, + { + "name": "user_token_y", + "writable": true + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "system_program" + "name": "token_program_x" }, { - "name": "rent" + "name": "token_program_y" }, { - "name": "event_authority" + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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" @@ -839,59 +1276,104 @@ ], "args": [ { - "name": "lower_bin_id", + "name": "min_bin_id", "type": "i32" }, { - "name": "width", + "name": "max_bin_id", "type": "i32" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } + } } ] }, { - "name": "initialize_position_pda", + "name": "claim_reward", "discriminator": [ - 46, - 82, - 125, - 146, - 85, - 141, - 228, - 153 + 149, + 95, + 181, + 242, + 94, + 90, + 158, + 162 ], "accounts": [ { - "name": "payer", + "name": "lb_pair", "writable": true, - "signer": true + "relations": [ + "position", + "bin_array_lower", + "bin_array_upper" + ] }, { - "name": "base", - "signer": true + "name": "position", + "writable": true }, { - "name": "position", + "name": "bin_array_lower", "writable": true }, { - "name": "lb_pair" + "name": "bin_array_upper", + "writable": true }, { - "name": "owner", - "docs": [ - "owner" - ], + "name": "sender", "signer": true }, { - "name": "system_program" + "name": "reward_vault", + "writable": true + }, + { + "name": "reward_mint" }, { - "name": "rent" + "name": "user_token_account", + "writable": true }, { - "name": "event_authority" + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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" @@ -899,65 +1381,85 @@ ], "args": [ { - "name": "lower_bin_id", - "type": "i32" - }, - { - "name": "width", - "type": "i32" + "name": "reward_index", + "type": "u64" } ] }, { - "name": "initialize_position_by_operator", + "name": "claim_reward2", "discriminator": [ - 251, - 189, 190, - 244, - 117, - 254, - 35, - 148 + 3, + 127, + 119, + 178, + 87, + 157, + 183 ], "accounts": [ { - "name": "payer", + "name": "lb_pair", "writable": true, - "signer": true - }, - { - "name": "base", - "signer": true + "relations": [ + "position" + ] }, { "name": "position", "writable": true }, { - "name": "lb_pair" - }, - { - "name": "owner" + "name": "sender", + "signer": true }, { - "name": "operator", - "docs": [ - "operator" - ], - "signer": true + "name": "reward_vault", + "writable": true }, { - "name": "operator_token_x" + "name": "reward_mint" }, { - "name": "owner_token_x" + "name": "user_token_account", + "writable": true }, { - "name": "system_program" + "name": "token_program" }, { - "name": "event_authority" + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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" @@ -965,282 +1467,454 @@ ], "args": [ { - "name": "lower_bin_id", - "type": "i32" + "name": "reward_index", + "type": "u64" }, { - "name": "width", + "name": "min_bin_id", "type": "i32" }, { - "name": "fee_owner", - "type": "pubkey" + "name": "max_bin_id", + "type": "i32" }, { - "name": "lock_release_point", - "type": "u64" + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } + } } ] }, { - "name": "update_position_operator", + "name": "close_claim_protocol_fee_operator", "discriminator": [ - 202, - 184, - 103, - 143, - 180, - 191, - 116, - 217 + 8, + 41, + 87, + 35, + 80, + 48, + 121, + 26 ], "accounts": [ { - "name": "position", + "name": "claim_fee_operator", "writable": true }, { - "name": "owner", - "signer": true - }, - { - "name": "event_authority" + "name": "rent_receiver", + "writable": true }, { - "name": "program" + "name": "admin", + "signer": true } ], - "args": [ - { - "name": "operator", - "type": "pubkey" - } - ] + "args": [] }, { - "name": "swap", + "name": "close_position", "discriminator": [ - 248, - 198, - 158, - 145, - 225, - 117, - 135, - 200 + 123, + 134, + 81, + 0, + 49, + 68, + 98, + 98 ], "accounts": [ { - "name": "lb_pair", + "name": "position", "writable": true }, { - "name": "bin_array_bitmap_extension", - "optional": true + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_lower", + "bin_array_upper" + ] }, { - "name": "reserve_x", + "name": "bin_array_lower", "writable": true }, { - "name": "reserve_y", + "name": "bin_array_upper", "writable": true }, { - "name": "user_token_in", - "writable": true + "name": "sender", + "signer": true }, { - "name": "user_token_out", + "name": "rent_receiver", "writable": true }, { - "name": "token_x_mint" + "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": "token_y_mint" - }, + "name": "program" + } + ], + "args": [] + }, + { + "name": "close_position2", + "discriminator": [ + 174, + 90, + 35, + 115, + 186, + 40, + 147, + 226 + ], + "accounts": [ { - "name": "oracle", + "name": "position", "writable": true }, { - "name": "host_fee_in", - "writable": true, - "optional": true - }, - { - "name": "user", + "name": "sender", "signer": true }, { - "name": "token_x_program" - }, - { - "name": "token_y_program" + "name": "rent_receiver", + "writable": true }, { - "name": "event_authority" + "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": "amount_in", - "type": "u64" - }, - { - "name": "min_amount_out", - "type": "u64" - } - ] + "args": [] }, { - "name": "swap_exact_out", + "name": "close_position_if_empty", "discriminator": [ - 250, - 73, - 101, - 33, - 38, - 207, - 75, - 184 + 59, + 124, + 212, + 118, + 91, + 152, + 110, + 157 ], "accounts": [ { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "optional": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", + "name": "position", "writable": true }, { - "name": "user_token_in", - "writable": true + "name": "sender", + "signer": true }, { - "name": "user_token_out", + "name": "rent_receiver", "writable": true }, { - "name": "token_x_mint" + "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": "token_y_mint" - }, + "name": "program" + } + ], + "args": [] + }, + { + "name": "close_preset_parameter", + "discriminator": [ + 4, + 148, + 145, + 100, + 134, + 26, + 181, + 61 + ], + "accounts": [ { - "name": "oracle", + "name": "preset_parameter", "writable": true }, { - "name": "host_fee_in", + "name": "admin", "writable": true, - "optional": true - }, - { - "name": "user", "signer": true }, { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + "name": "rent_receiver", + "writable": true } ], - "args": [ - { - "name": "max_in_amount", - "type": "u64" - }, - { - "name": "out_amount", - "type": "u64" - } - ] + "args": [] }, { - "name": "swap_with_price_impact", + "name": "close_preset_parameter2", "discriminator": [ - 56, - 173, - 230, - 208, - 173, - 228, - 156, - 205 + 39, + 25, + 95, + 107, + 116, + 17, + 115, + 28 ], "accounts": [ { - "name": "lb_pair", + "name": "preset_parameter", "writable": true }, { - "name": "bin_array_bitmap_extension", - "optional": true - }, - { - "name": "reserve_x", - "writable": true + "name": "admin", + "writable": true, + "signer": true }, { - "name": "reserve_y", + "name": "rent_receiver", "writable": true - }, + } + ], + "args": [] + }, + { + "name": "close_token_badge", + "discriminator": [ + 108, + 146, + 86, + 110, + 179, + 254, + 10, + 104 + ], + "accounts": [ { - "name": "user_token_in", + "name": "token_badge", "writable": true }, { - "name": "user_token_out", + "name": "rent_receiver", "writable": true }, { - "name": "token_x_mint" - }, + "name": "admin", + "signer": true + } + ], + "args": [] + }, + { + "name": "create_claim_protocol_fee_operator", + "discriminator": [ + 51, + 19, + 150, + 252, + 105, + 157, + 48, + 91 + ], + "accounts": [ { - "name": "token_y_mint" + "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": "oracle", - "writable": true + "name": "operator" }, { - "name": "host_fee_in", + "name": "admin", "writable": true, - "optional": true - }, - { - "name": "user", "signer": true }, { - "name": "token_x_program" + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "decrease_position_length", + "discriminator": [ + 194, + 219, + 136, + 32, + 25, + 96, + 105, + 37 + ], + "accounts": [ + { + "name": "rent_receiver", + "writable": true }, { - "name": "token_y_program" + "name": "position", + "writable": true }, { - "name": "event_authority" + "name": "owner", + "signer": true, + "relations": [ + "position" + ] + }, + { + "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" @@ -1248,163 +1922,43 @@ ], "args": [ { - "name": "amount_in", - "type": "u64" + "name": "length_to_remove", + "type": "u16" }, { - "name": "active_id", - "type": { - "option": "i32" - } - }, - { - "name": "max_price_impact_bps", - "type": "u16" + "name": "side", + "type": "u8" } ] }, { - "name": "withdraw_protocol_fee", + "name": "for_idl_type_generation_do_not_call", "discriminator": [ - 158, - 201, - 158, - 189, - 33, - 93, - 162, - 103 + 180, + 105, + 69, + 80, + 95, + 50, + 73, + 108 ], "accounts": [ { - "name": "lb_pair", - "writable": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "receiver_token_x", - "writable": true - }, - { - "name": "receiver_token_y", - "writable": true - }, - { - "name": "claim_fee_operator" - }, - { - "name": "operator", - "docs": [ - "operator" - ], - "signer": true - }, - { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "memo_program" + "name": "dummy_zc_account" } ], "args": [ { - "name": "amount_x", - "type": "u64" - }, - { - "name": "amount_y", - "type": "u64" - }, - { - "name": "remaining_accounts_info", + "name": "_ix", "type": { "defined": { - "name": "RemainingAccountsInfo" + "name": "DummyIx" } } } ] }, - { - "name": "initialize_reward", - "discriminator": [ - 95, - 135, - 192, - 196, - 242, - 129, - 230, - 68 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "reward_vault", - "writable": true - }, - { - "name": "reward_mint" - }, - { - "name": "token_badge", - "optional": true - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "token_program" - }, - { - "name": "system_program" - }, - { - "name": "rent" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "reward_index", - "type": "u64" - }, - { - "name": "reward_duration", - "type": "u64" - }, - { - "name": "funder", - "type": "pubkey" - } - ] - }, { "name": "fund_reward", "discriminator": [ @@ -1420,7 +1974,10 @@ "accounts": [ { "name": "lb_pair", - "writable": true + "writable": true, + "relations": [ + "bin_array" + ] }, { "name": "reward_vault", @@ -1445,7 +2002,33 @@ "name": "token_program" }, { - "name": "event_authority" + "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" @@ -1475,28 +2058,67 @@ ] }, { - "name": "update_reward_funder", + "name": "go_to_a_bin", "discriminator": [ - 211, - 28, - 48, - 32, - 215, - 160, - 35, - 23 + 146, + 72, + 174, + 224, + 40, + 253, + 84, + 174 ], "accounts": [ { "name": "lb_pair", - "writable": true + "writable": true, + "relations": [ + "bin_array_bitmap_extension", + "from_bin_array", + "to_bin_array" + ] }, { - "name": "admin", - "signer": true + "name": "bin_array_bitmap_extension", + "optional": true }, { - "name": "event_authority" + "name": "from_bin_array", + "optional": true + }, + { + "name": "to_bin_array", + "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" @@ -1504,42 +2126,65 @@ ], "args": [ { - "name": "reward_index", - "type": "u64" - }, - { - "name": "new_funder", - "type": "pubkey" + "name": "bin_id", + "type": "i32" } ] }, { - "name": "update_reward_duration", + "name": "increase_oracle_length", "discriminator": [ - 138, - 174, - 196, - 169, - 213, - 235, - 254, - 107 + 190, + 61, + 125, + 87, + 103, + 79, + 158, + 173 ], "accounts": [ { - "name": "lb_pair", + "name": "oracle", "writable": true }, { - "name": "admin", + "name": "funder", + "writable": true, "signer": true }, { - "name": "bin_array", - "writable": true - }, - { - "name": "event_authority" + "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" @@ -1547,64 +2192,161 @@ ], "args": [ { - "name": "reward_index", - "type": "u64" - }, - { - "name": "new_duration", + "name": "length_to_add", "type": "u64" } ] }, { - "name": "claim_reward", + "name": "increase_position_length", "discriminator": [ - 149, - 95, - 181, - 242, - 94, - 90, - 158, - 162 + 80, + 83, + 117, + 211, + 66, + 13, + 33, + 149 ], "accounts": [ { - "name": "lb_pair", - "writable": true + "name": "funder", + "writable": true, + "signer": true }, { - "name": "position", - "writable": true + "name": "lb_pair", + "relations": [ + "position" + ] }, { - "name": "bin_array_lower", + "name": "position", "writable": true }, { - "name": "bin_array_upper", - "writable": true + "name": "owner", + "signer": true, + "relations": [ + "position" + ] + }, + { + "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": "sender", - "signer": true - }, + "name": "program" + } + ], + "args": [ { - "name": "reward_vault", - "writable": true + "name": "length_to_add", + "type": "u16" }, { - "name": "reward_mint" + "name": "side", + "type": "u8" + } + ] + }, + { + "name": "increase_position_length2", + "discriminator": [ + 255, + 210, + 204, + 71, + 115, + 137, + 225, + 113 + ], + "accounts": [ + { + "name": "funder", + "writable": true, + "signer": true }, { - "name": "user_token_account", - "writable": true + "name": "lb_pair", + "relations": [ + "position" + ] }, { - "name": "token_program" + "name": "position", + "writable": true }, { - "name": "event_authority" + "name": "owner", + "signer": true, + "relations": [ + "position" + ] + }, + { + "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" @@ -1612,186 +2354,281 @@ ], "args": [ { - "name": "reward_index", - "type": "u64" + "name": "minimum_upper_bin_id", + "type": "i32" } ] }, { - "name": "claim_fee", + "name": "initialize_bin_array", "discriminator": [ - 169, - 32, - 79, - 137, - 136, - 232, - 70, - 137 + 35, + 86, + 19, + 185, + 78, + 212, + 75, + 211 ], "accounts": [ { - "name": "lb_pair", - "writable": true - }, - { - "name": "position", - "writable": true - }, - { - "name": "bin_array_lower", - "writable": true + "name": "lb_pair" }, { - "name": "bin_array_upper", - "writable": true + "name": "bin_array", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 110, + 95, + 97, + 114, + 114, + 97, + 121 + ] + }, + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "arg", + "path": "index" + } + ] + } }, { - "name": "sender", + "name": "funder", + "writable": true, "signer": true }, { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "user_token_x", - "writable": true - }, + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ { - "name": "user_token_y", - "writable": true - }, + "name": "index", + "type": "i64" + } + ] + }, + { + "name": "initialize_bin_array_bitmap_extension", + "discriminator": [ + 47, + 157, + 226, + 180, + 12, + 240, + 33, + 71 + ], + "accounts": [ { - "name": "token_x_mint" + "name": "lb_pair" }, { - "name": "token_y_mint" + "name": "bin_array_bitmap_extension", + "docs": [ + "Initialize an account to store if a bin array is initialized." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 116, + 109, + 97, + 112 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] + } }, { - "name": "token_program" + "name": "funder", + "writable": true, + "signer": true }, { - "name": "event_authority" + "name": "system_program", + "address": "11111111111111111111111111111111" }, { - "name": "program" + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" } ], "args": [] }, { - "name": "close_position", + "name": "initialize_customizable_permissionless_lb_pair", "discriminator": [ - 123, - 134, - 81, - 0, - 49, - 68, - 98, - 98 + 46, + 39, + 41, + 135, + 111, + 183, + 200, + 64 ], "accounts": [ - { - "name": "position", - "writable": true - }, { "name": "lb_pair", "writable": true }, { - "name": "bin_array_lower", - "writable": true + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 116, + 109, + 97, + 112 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] + } }, { - "name": "bin_array_upper", - "writable": true + "name": "token_mint_x" }, { - "name": "sender", - "signer": true + "name": "token_mint_y" }, { - "name": "rent_receiver", - "writable": true + "name": "reserve_x", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_x" + } + ] + } }, { - "name": "event_authority" + "name": "reserve_y", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_y" + } + ] + } }, { - "name": "program" - } - ], - "args": [] - }, - { - "name": "update_base_fee_parameters", - "discriminator": [ - 75, - 168, - 223, - 161, - 16, - 195, - 3, - 47 - ], - "accounts": [ + "name": "oracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] + } + }, { - "name": "lb_pair", - "writable": true + "name": "user_token_x" }, { - "name": "admin", + "name": "funder", + "writable": true, "signer": true }, { - "name": "event_authority" + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" }, { - "name": "program" - } - ], - "args": [ - { - "name": "fee_parameter", - "type": { - "defined": { - "name": "BaseFeeParameter" - } - } - } - ] - }, - { - "name": "update_dynamic_fee_parameters", - "discriminator": [ - 92, - 161, - 46, - 246, - 255, - 189, - 22, - 22 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true + "name": "system_program", + "address": "11111111111111111111111111111111" }, { - "name": "admin", - "signer": true + "name": "user_token_y" }, { - "name": "event_authority" + "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" @@ -1799,169 +2636,369 @@ ], "args": [ { - "name": "fee_parameter", + "name": "params", "type": { "defined": { - "name": "DynamicFeeParameter" + "name": "CustomizableParams" } } } ] }, { - "name": "increase_oracle_length", + "name": "initialize_customizable_permissionless_lb_pair2", "discriminator": [ - 190, - 61, - 125, - 87, - 103, - 79, - 158, - 173 + 243, + 73, + 129, + 126, + 51, + 19, + 241, + 107 ], "accounts": [ { - "name": "oracle", + "name": "lb_pair", "writable": true }, { - "name": "funder", + "name": "bin_array_bitmap_extension", "writable": true, - "signer": true + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 116, + 109, + 97, + 112 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] + } }, { - "name": "system_program" + "name": "token_mint_x" }, { - "name": "event_authority" + "name": "token_mint_y" }, { - "name": "program" - } - ], - "args": [ + "name": "reserve_x", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_x" + } + ] + } + }, { - "name": "length_to_add", - "type": "u64" - } - ] - }, - { - "name": "initialize_preset_parameter", - "discriminator": [ - 66, - 188, - 71, - 211, - 98, - 109, - 14, - 186 - ], - "accounts": [ + "name": "reserve_y", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_y" + } + ] + } + }, { - "name": "preset_parameter", - "writable": true + "name": "oracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] + } }, { - "name": "admin", + "name": "user_token_x" + }, + { + "name": "funder", "writable": true, "signer": true }, { - "name": "system_program" + "name": "token_badge_x", + "optional": true + }, + { + "name": "token_badge_y", + "optional": true + }, + { + "name": "token_program_x" + }, + { + "name": "token_program_y" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "user_token_y" + }, + { + "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": "rent" + "name": "program" } ], "args": [ { - "name": "ix", + "name": "params", "type": { "defined": { - "name": "InitPresetParametersIx" + "name": "CustomizableParams" } } } ] }, { - "name": "close_preset_parameter", + "name": "initialize_lb_pair", "discriminator": [ - 4, - 148, - 145, - 100, - 134, - 26, - 181, - 61 + 45, + 154, + 237, + 210, + 221, + 15, + 166, + 92 ], "accounts": [ { - "name": "preset_parameter", + "name": "lb_pair", "writable": true }, { - "name": "admin", + "name": "bin_array_bitmap_extension", "writable": true, - "signer": true + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 116, + 109, + 97, + 112 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] + } }, { - "name": "rent_receiver", - "writable": true - } - ], - "args": [] - }, - { - "name": "close_preset_parameter2", - "discriminator": [ - 39, - 25, - 95, - 107, - 116, - 17, - 115, - 28 - ], - "accounts": [ + "name": "token_mint_x" + }, { - "name": "preset_parameter", - "writable": true + "name": "token_mint_y" }, { - "name": "admin", + "name": "reserve_x", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_x" + } + ] + } + }, + { + "name": "reserve_y", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_y" + } + ] + } + }, + { + "name": "oracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] + } + }, + { + "name": "preset_parameter" + }, + { + "name": "funder", "writable": true, "signer": true }, { - "name": "rent_receiver", - "writable": true + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "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": [] + "args": [ + { + "name": "active_id", + "type": "i32" + }, + { + "name": "bin_step", + "type": "u16" + } + ] }, { - "name": "remove_all_liquidity", + "name": "initialize_lb_pair2", "discriminator": [ - 10, - 51, - 61, - 35, - 112, - 105, - 24, - 85 + 73, + 59, + 36, + 120, + 237, + 83, + 108, + 198 ], "accounts": [ - { - "name": "position", - "writable": true - }, { "name": "lb_pair", "writable": true @@ -1969,239 +3006,605 @@ { "name": "bin_array_bitmap_extension", "writable": true, - "optional": true + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 116, + 109, + 97, + 112 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] + } }, { - "name": "user_token_x", - "writable": true + "name": "token_mint_x" }, { - "name": "user_token_y", - "writable": true + "name": "token_mint_y" }, { "name": "reserve_x", - "writable": true + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_x" + } + ] + } }, { "name": "reserve_y", - "writable": true + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_y" + } + ] + } }, { - "name": "token_x_mint" + "name": "oracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] + } }, { - "name": "token_y_mint" + "name": "preset_parameter" }, { - "name": "bin_array_lower", - "writable": true + "name": "funder", + "writable": true, + "signer": true }, { - "name": "bin_array_upper", - "writable": true + "name": "token_badge_x", + "optional": true }, { - "name": "sender", - "signer": true + "name": "token_badge_y", + "optional": true }, { - "name": "token_x_program" + "name": "token_program_x" }, { - "name": "token_y_program" + "name": "token_program_y" }, { - "name": "event_authority" + "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": [] + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "InitializeLbPair2Params" + } + } + } + ] }, { - "name": "set_pair_status", + "name": "initialize_permission_lb_pair", "discriminator": [ - 67, - 248, - 231, - 137, - 154, - 149, - 217, - 174 + 108, + 102, + 213, + 85, + 251, + 3, + 53, + 21 ], "accounts": [ + { + "name": "base", + "signer": true + }, { "name": "lb_pair", "writable": true }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 116, + 109, + 97, + 112 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] + } + }, + { + "name": "token_mint_x" + }, + { + "name": "token_mint_y" + }, + { + "name": "reserve_x", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_x" + } + ] + } + }, + { + "name": "reserve_y", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_y" + } + ] + } + }, + { + "name": "oracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] + } + }, { "name": "admin", + "writable": true, "signer": true + }, + { + "name": "token_badge_x", + "optional": true + }, + { + "name": "token_badge_y", + "optional": true + }, + { + "name": "token_program_x" + }, + { + "name": "token_program_y" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "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": "ix_data", + "type": { + "defined": { + "name": "InitPermissionPairIx" + } + } } ] }, { - "name": "migrate_position", + "name": "initialize_position", "discriminator": [ - 15, - 132, - 59, - 50, - 199, - 6, - 251, - 46 + 219, + 192, + 234, + 71, + 190, + 191, + 102, + 80 ], "accounts": [ { - "name": "position_v2", + "name": "payer", "writable": true, "signer": true }, { - "name": "position_v1", - "writable": true + "name": "position", + "writable": true, + "signer": true }, { "name": "lb_pair" }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, { "name": "owner", - "writable": true, "signer": true }, { - "name": "system_program" - }, - { - "name": "rent_receiver", - "writable": true - }, - { - "name": "event_authority" + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "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": "migrate_bin_array", - "discriminator": [ - 17, - 23, - 159, - 211, - 101, - 184, - 41, - 241 - ], - "accounts": [ + "args": [ { - "name": "lb_pair" + "name": "lower_bin_id", + "type": "i32" + }, + { + "name": "width", + "type": "i32" } - ], - "args": [] + ] }, { - "name": "update_fees_and_rewards", + "name": "initialize_position2", "discriminator": [ - 154, - 230, - 250, - 13, - 236, - 209, - 75, - 223 + 143, + 19, + 242, + 145, + 213, + 15, + 104, + 115 ], "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, { "name": "position", - "writable": true + "writable": true, + "signer": true }, { - "name": "lb_pair", - "writable": true + "name": "lb_pair" }, { - "name": "bin_array_lower", - "writable": true + "name": "owner", + "signer": true }, { - "name": "bin_array_upper", - "writable": 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": "owner", - "signer": true + "name": "program" } ], - "args": [] + "args": [ + { + "name": "lower_bin_id", + "type": "i32" + }, + { + "name": "width", + "type": "i32" + } + ] }, { - "name": "withdraw_ineligible_reward", + "name": "initialize_position_by_operator", "discriminator": [ - 148, - 206, - 42, - 195, - 247, - 49, - 103, - 8 + 251, + 189, + 190, + 244, + 117, + 254, + 35, + 148 ], "accounts": [ { - "name": "lb_pair", - "writable": true + "name": "payer", + "writable": true, + "signer": true }, { - "name": "reward_vault", - "writable": true + "name": "base", + "signer": true }, { - "name": "reward_mint" + "name": "position", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 111, + 115, + 105, + 116, + 105, + 111, + 110 + ] + }, + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "base" + }, + { + "kind": "arg", + "path": "lower_bin_id" + }, + { + "kind": "arg", + "path": "width" + } + ] + } }, { - "name": "funder_token_account", - "writable": true + "name": "lb_pair" }, { - "name": "funder", - "signer": true + "name": "owner" }, { - "name": "bin_array", - "writable": true + "name": "operator", + "docs": [ + "operator" + ], + "signer": true }, { - "name": "token_program" + "name": "operator_token_x" }, { - "name": "memo_program" + "name": "owner_token_x" }, { - "name": "event_authority" + "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" @@ -2209,117 +3612,128 @@ ], "args": [ { - "name": "reward_index", - "type": "u64" + "name": "lower_bin_id", + "type": "i32" }, { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" - } - } + "name": "width", + "type": "i32" + }, + { + "name": "fee_owner", + "type": "pubkey" + }, + { + "name": "lock_release_point", + "type": "u64" } ] }, { - "name": "set_activation_point", + "name": "initialize_position_pda", "discriminator": [ - 91, - 249, - 15, - 165, - 26, - 129, - 254, - 125 + 46, + 82, + 125, + 146, + 85, + 141, + 228, + 153 ], "accounts": [ { - "name": "lb_pair", - "writable": true - }, - { - "name": "admin", + "name": "payer", "writable": true, "signer": true - } - ], - "args": [ - { - "name": "activation_point", - "type": "u64" - } - ] - }, - { - "name": "remove_liquidity_by_range", - "discriminator": [ - 26, - 82, - 102, - 152, - 240, - 74, - 105, - 26 - ], - "accounts": [ - { - "name": "position", - "writable": true }, { - "name": "lb_pair", - "writable": true + "name": "base", + "signer": true }, { - "name": "bin_array_bitmap_extension", + "name": "position", "writable": true, - "optional": true - }, - { - "name": "user_token_x", - "writable": true - }, - { - "name": "user_token_y", - "writable": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "bin_array_lower", - "writable": true + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 111, + 115, + 105, + 116, + 105, + 111, + 110 + ] + }, + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "base" + }, + { + "kind": "arg", + "path": "lower_bin_id" + }, + { + "kind": "arg", + "path": "width" + } + ] + } }, { - "name": "bin_array_upper", - "writable": true + "name": "lb_pair" }, { - "name": "sender", + "name": "owner", + "docs": [ + "owner" + ], "signer": true }, { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "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" @@ -2327,100 +3741,169 @@ ], "args": [ { - "name": "from_bin_id", + "name": "lower_bin_id", "type": "i32" }, { - "name": "to_bin_id", + "name": "width", "type": "i32" - }, - { - "name": "bps_to_remove", - "type": "u16" } ] }, { - "name": "add_liquidity_one_side_precise", + "name": "initialize_preset_parameter", "discriminator": [ - 161, - 194, - 103, - 84, - 171, + 66, + 188, 71, - 250, - 154 + 211, + 98, + 109, + 14, + 186 ], "accounts": [ { - "name": "position", - "writable": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", + "name": "preset_parameter", "writable": true, - "optional": true + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 101, + 115, + 101, + 116, + 95, + 112, + 97, + 114, + 97, + 109, + 101, + 116, + 101, + 114 + ] + }, + { + "kind": "arg", + "path": "ix.bin_step" + }, + { + "kind": "arg", + "path": "ix.base_factor" + } + ] + } }, { - "name": "user_token", - "writable": true + "name": "admin", + "writable": true, + "signer": true }, { - "name": "reserve", - "writable": true + "name": "system_program", + "address": "11111111111111111111111111111111" }, { - "name": "token_mint" - }, + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + } + ], + "args": [ { - "name": "bin_array_lower", - "writable": true - }, + "name": "ix", + "type": { + "defined": { + "name": "InitPresetParametersIx" + } + } + } + ] + }, + { + "name": "initialize_preset_parameter2", + "discriminator": [ + 184, + 7, + 240, + 171, + 103, + 47, + 183, + 121 + ], + "accounts": [ { - "name": "bin_array_upper", - "writable": true + "name": "preset_parameter", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 101, + 115, + 101, + 116, + 95, + 112, + 97, + 114, + 97, + 109, + 101, + 116, + 101, + 114, + 50 + ] + }, + { + "kind": "arg", + "path": "ix.index" + } + ] + } }, { - "name": "sender", + "name": "admin", + "writable": true, "signer": true }, { - "name": "token_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "parameter", + "name": "ix", "type": { "defined": { - "name": "AddLiquiditySingleSidePreciseParameter" + "name": "InitPresetParameters2Ix" } } } ] }, { - "name": "go_to_a_bin", + "name": "initialize_reward", "discriminator": [ - 146, - 72, - 174, - 224, - 40, - 253, - 84, - 174 + 95, + 135, + 192, + 196, + 242, + 129, + 230, + 68 ], "accounts": [ { @@ -2428,19 +3911,72 @@ "writable": true }, { - "name": "bin_array_bitmap_extension", - "optional": true + "name": "reward_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "arg", + "path": "reward_index" + } + ] + } }, { - "name": "from_bin_array", - "optional": true + "name": "reward_mint" }, { - "name": "to_bin_array", + "name": "token_badge", "optional": true }, { - "name": "event_authority" + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "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" @@ -2448,241 +3984,207 @@ ], "args": [ { - "name": "bin_id", - "type": "i32" + "name": "reward_index", + "type": "u64" + }, + { + "name": "reward_duration", + "type": "u64" + }, + { + "name": "funder", + "type": "pubkey" } ] }, { - "name": "set_pre_activation_duration", + "name": "initialize_token_badge", "discriminator": [ - 165, - 61, - 201, - 244, - 130, - 159, - 22, - 100 + 253, + 77, + 205, + 95, + 27, + 224, + 89, + 223 ], "accounts": [ { - "name": "lb_pair", - "writable": true + "name": "token_mint" }, { - "name": "creator", - "signer": true - } - ], - "args": [ - { - "name": "pre_activation_duration", - "type": "u64" - } - ] - }, - { - "name": "set_pre_activation_swap_address", - "discriminator": [ - 57, - 139, - 47, - 123, - 216, - 80, - 223, - 10 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true + "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": "creator", + "name": "admin", + "writable": true, "signer": true - } - ], - "args": [ + }, { - "name": "pre_activation_swap_address", - "type": "pubkey" + "name": "system_program", + "address": "11111111111111111111111111111111" } - ] + ], + "args": [] }, { - "name": "set_pair_status_permissionless", + "name": "migrate_bin_array", "discriminator": [ - 78, - 59, - 152, + 17, + 23, + 159, 211, - 70, - 183, - 46, - 208 + 101, + 184, + 41, + 241 ], "accounts": [ { - "name": "lb_pair", - "writable": true - }, - { - "name": "creator", - "signer": true + "name": "lb_pair" } ], - "args": [ - { - "name": "status", - "type": "u8" - } - ] + "args": [] }, { - "name": "initialize_token_badge", + "name": "migrate_position", "discriminator": [ - 253, - 77, - 205, - 95, - 27, - 224, - 89, - 223 + 15, + 132, + 59, + 50, + 199, + 6, + 251, + 46 ], "accounts": [ { - "name": "token_mint" + "name": "position_v2", + "writable": true, + "signer": true }, { - "name": "token_badge", + "name": "position_v1", "writable": true }, { - "name": "admin", - "writable": true, - "signer": true + "name": "lb_pair", + "relations": [ + "position_v1", + "bin_array_lower", + "bin_array_upper" + ] }, { - "name": "system_program" - } - ], - "args": [] - }, - { - "name": "create_claim_protocol_fee_operator", - "discriminator": [ - 51, - 19, - 150, - 252, - 105, - 157, - 48, - 91 - ], - "accounts": [ - { - "name": "claim_fee_operator", + "name": "bin_array_lower", "writable": true }, { - "name": "operator" + "name": "bin_array_upper", + "writable": true }, { - "name": "admin", + "name": "owner", "writable": true, - "signer": true + "signer": true, + "relations": [ + "position_v1" + ] }, { - "name": "system_program" - } - ], - "args": [] - }, - { - "name": "close_claim_protocol_fee_operator", - "discriminator": [ - 8, - 41, - 87, - 35, - 80, - 48, - 121, - 26 - ], - "accounts": [ - { - "name": "claim_fee_operator", - "writable": true + "name": "system_program", + "address": "11111111111111111111111111111111" }, { "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": "initialize_preset_parameter2", + "name": "rebalance_liquidity", "discriminator": [ - 184, - 7, - 240, - 171, - 103, - 47, - 183, - 121 + 92, + 4, + 176, + 193, + 119, + 185, + 83, + 9 ], "accounts": [ { - "name": "preset_parameter", + "name": "position", "writable": true }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "system_program" - } - ], - "args": [ - { - "name": "ix", - "type": { - "defined": { - "name": "InitPresetParameters2Ix" - } - } - } - ] - }, - { - "name": "initialize_lb_pair2", - "discriminator": [ - 73, - 59, - 36, - 120, - 237, - 83, - 108, - 198 - ], - "accounts": [ { "name": "lb_pair", - "writable": true + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension" + ] }, { "name": "bin_array_bitmap_extension", @@ -2690,50 +4192,93 @@ "optional": true }, { - "name": "token_mint_x" - }, - { - "name": "token_mint_y" - }, - { - "name": "reserve_x", + "name": "user_token_x", "writable": true }, { - "name": "reserve_y", + "name": "user_token_y", "writable": true }, { - "name": "oracle", - "writable": true + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "preset_parameter" + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "funder", - "writable": true, - "signer": true + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "token_badge_x", - "optional": true + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "token_badge_y", - "optional": true + "name": "owner", + "signer": true, + "relations": [ + "position" + ] }, { - "name": "token_program_x" + "name": "rent_payer", + "writable": true, + "signer": true }, { - "name": "token_program_y" + "name": "token_x_program" }, { - "name": "system_program" + "name": "token_y_program" }, { - "name": "event_authority" + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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" @@ -2744,130 +4289,172 @@ "name": "params", "type": { "defined": { - "name": "InitializeLbPair2Params" + "name": "RebalanceLiquidityParams" + } + } + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" } } } ] }, { - "name": "initialize_customizable_permissionless_lb_pair2", + "name": "remove_all_liquidity", "discriminator": [ - 243, - 73, - 129, - 126, + 10, 51, - 19, - 241, - 107 - ], + 61, + 35, + 112, + 105, + 24, + 85 + ], "accounts": [ { - "name": "lb_pair", + "name": "position", "writable": true }, { - "name": "bin_array_bitmap_extension", + "name": "lb_pair", "writable": true, - "optional": true - }, - { - "name": "token_mint_x" - }, - { - "name": "token_mint_y" + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] }, { - "name": "reserve_x", - "writable": true + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true }, { - "name": "reserve_y", + "name": "user_token_x", "writable": true }, { - "name": "oracle", + "name": "user_token_y", "writable": true }, { - "name": "user_token_x" - }, - { - "name": "funder", + "name": "reserve_x", "writable": true, - "signer": true + "relations": [ + "lb_pair" + ] }, { - "name": "token_badge_x", - "optional": true + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "token_badge_y", - "optional": true + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "token_program_x" + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "token_program_y" + "name": "bin_array_lower", + "writable": true }, { - "name": "system_program" + "name": "bin_array_upper", + "writable": true }, { - "name": "user_token_y" + "name": "sender", + "signer": true }, { - "name": "event_authority" + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "CustomizableParams" - } - } - } - ] + "args": [] }, { - "name": "claim_fee2", + "name": "remove_liquidity", "discriminator": [ - 112, - 191, - 101, - 171, - 28, - 144, - 127, - 187 + 80, + 85, + 209, + 72, + 24, + 206, + 177, + 108 ], "accounts": [ - { - "name": "lb_pair", - "writable": true - }, { "name": "position", "writable": true }, { - "name": "sender", - "signer": true - }, - { - "name": "reserve_x", - "writable": true + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] }, { - "name": "reserve_y", - "writable": true + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true }, { "name": "user_token_x", @@ -2878,65 +4465,37 @@ "writable": true }, { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "token_program_x" - }, - { - "name": "token_program_y" - }, - { - "name": "memo_program" + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "event_authority" + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "program" - } - ], - "args": [ - { - "name": "min_bin_id", - "type": "i32" + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "max_bin_id", - "type": "i32" + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" - } - } - } - ] - }, - { - "name": "claim_reward2", - "discriminator": [ - 190, - 3, - 127, - 119, - 178, - 87, - 157, - 183 - ], - "accounts": [ - { - "name": "lb_pair", + "name": "bin_array_lower", "writable": true }, { - "name": "position", + "name": "bin_array_upper", "writable": true }, { @@ -2944,24 +4503,41 @@ "signer": true }, { - "name": "reward_vault", - "writable": true - }, - { - "name": "reward_mint" - }, - { - "name": "user_token_account", - "writable": true - }, - { - "name": "token_program" - }, - { - "name": "memo_program" - }, - { - "name": "event_authority" + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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" @@ -2969,38 +4545,28 @@ ], "args": [ { - "name": "reward_index", - "type": "u64" - }, - { - "name": "min_bin_id", - "type": "i32" - }, - { - "name": "max_bin_id", - "type": "i32" - }, - { - "name": "remaining_accounts_info", + "name": "bin_liquidity_removal", "type": { - "defined": { - "name": "RemainingAccountsInfo" + "vec": { + "defined": { + "name": "BinLiquidityReduction" + } } } } ] }, { - "name": "add_liquidity2", + "name": "remove_liquidity2", "discriminator": [ - 228, - 162, - 78, - 28, - 70, - 219, - 116, - 115 + 230, + 215, + 82, + 127, + 241, + 101, + 227, + 146 ], "accounts": [ { @@ -3009,7 +4575,11 @@ }, { "name": "lb_pair", - "writable": true + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension" + ] }, { "name": "bin_array_bitmap_extension", @@ -3026,17 +4596,29 @@ }, { "name": "reserve_x", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { "name": "reserve_y", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "token_x_mint" + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "token_y_mint" + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] }, { "name": "sender", @@ -3049,7 +4631,37 @@ "name": "token_y_program" }, { - "name": "event_authority" + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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" @@ -3057,10 +4669,12 @@ ], "args": [ { - "name": "liquidity_parameter", + "name": "bin_liquidity_removal", "type": { - "defined": { - "name": "LiquidityParameter" + "vec": { + "defined": { + "name": "BinLiquidityReduction" + } } } }, @@ -3075,16 +4689,16 @@ ] }, { - "name": "add_liquidity_by_strategy2", + "name": "remove_liquidity_by_range", "discriminator": [ - 3, - 221, - 149, - 218, - 111, - 141, - 118, - 213 + 26, + 82, + 102, + 152, + 240, + 74, + 105, + 26 ], "accounts": [ { @@ -3093,7 +4707,13 @@ }, { "name": "lb_pair", - "writable": true + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] }, { "name": "bin_array_bitmap_extension", @@ -3110,30 +4730,78 @@ }, { "name": "reserve_x", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { "name": "reserve_y", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "token_x_mint" + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "token_y_mint" + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "sender", - "signer": true + "name": "bin_array_lower", + "writable": true }, { - "name": "token_x_program" + "name": "bin_array_upper", + "writable": true }, { - "name": "token_y_program" + "name": "sender", + "signer": true }, { - "name": "event_authority" + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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" @@ -3141,179 +4809,16 @@ ], "args": [ { - "name": "liquidity_parameter", - "type": { - "defined": { - "name": "LiquidityParameterByStrategy" - } - } - }, - { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" - } - } - } - ] - }, - { - "name": "add_liquidity_one_side_precise2", - "discriminator": [ - 33, - 51, - 163, - 201, - 117, - 98, - 125, - 231 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "user_token", - "writable": true - }, - { - "name": "reserve", - "writable": true - }, - { - "name": "token_mint" - }, - { - "name": "sender", - "signer": true - }, - { - "name": "token_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "liquidity_parameter", - "type": { - "defined": { - "name": "AddLiquiditySingleSidePreciseParameter2" - } - } - }, - { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" - } - } - } - ] - }, - { - "name": "remove_liquidity2", - "discriminator": [ - 230, - 215, - 82, - 127, - 241, - 101, - 227, - 146 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "user_token_x", - "writable": true - }, - { - "name": "user_token_y", - "writable": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "sender", - "signer": true - }, - { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "memo_program" - }, - { - "name": "event_authority" + "name": "from_bin_id", + "type": "i32" }, { - "name": "program" - } - ], - "args": [ - { - "name": "bin_liquidity_removal", - "type": { - "vec": { - "defined": { - "name": "BinLiquidityReduction" - } - } - } + "name": "to_bin_id", + "type": "i32" }, { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" - } - } + "name": "bps_to_remove", + "type": "u16" } ] }, @@ -3336,7 +4841,11 @@ }, { "name": "lb_pair", - "writable": true + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension" + ] }, { "name": "bin_array_bitmap_extension", @@ -3353,17 +4862,29 @@ }, { "name": "reserve_x", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { "name": "reserve_y", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "token_x_mint" + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "token_y_mint" + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] }, { "name": "sender", @@ -3376,10 +4897,37 @@ "name": "token_y_program" }, { - "name": "memo_program" - }, - { - "name": "event_authority" + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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" @@ -3409,16 +4957,16 @@ ] }, { - "name": "swap2", + "name": "set_activation_point", "discriminator": [ - 65, - 75, - 63, - 76, - 235, - 91, 91, - 136 + 249, + 15, + 165, + 26, + 129, + 254, + 125 ], "accounts": [ { @@ -3426,107 +4974,180 @@ "writable": true }, { - "name": "bin_array_bitmap_extension", - "optional": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "user_token_in", - "writable": true - }, - { - "name": "user_token_out", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "oracle", - "writable": true - }, - { - "name": "host_fee_in", + "name": "admin", "writable": true, - "optional": true - }, - { - "name": "user", "signer": true - }, - { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "memo_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" } ], "args": [ { - "name": "amount_in", - "type": "u64" - }, - { - "name": "min_amount_out", + "name": "activation_point", "type": "u64" - }, - { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" - } - } } ] }, { - "name": "swap_exact_out2", + "name": "set_pair_status", "discriminator": [ - 43, - 215, - 247, - 132, + 67, + 248, + 231, 137, - 60, - 243, - 81 + 154, + 149, + 217, + 174 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "admin", + "signer": true + } + ], + "args": [ + { + "name": "status", + "type": "u8" + } + ] + }, + { + "name": "set_pair_status_permissionless", + "discriminator": [ + 78, + 59, + 152, + 211, + 70, + 183, + 46, + 208 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "creator", + "signer": true, + "relations": [ + "lb_pair" + ] + } + ], + "args": [ + { + "name": "status", + "type": "u8" + } + ] + }, + { + "name": "set_pre_activation_duration", + "discriminator": [ + 165, + 61, + 201, + 244, + 130, + 159, + 22, + 100 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "creator", + "signer": true, + "relations": [ + "lb_pair" + ] + } + ], + "args": [ + { + "name": "pre_activation_duration", + "type": "u64" + } + ] + }, + { + "name": "set_pre_activation_swap_address", + "discriminator": [ + 57, + 139, + 47, + 123, + 216, + 80, + 223, + 10 ], "accounts": [ { "name": "lb_pair", "writable": true }, + { + "name": "creator", + "signer": true, + "relations": [ + "lb_pair" + ] + } + ], + "args": [ + { + "name": "pre_activation_swap_address", + "type": "pubkey" + } + ] + }, + { + "name": "swap", + "discriminator": [ + 248, + 198, + 158, + 145, + 225, + 117, + 135, + 200 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array_bitmap_extension" + ] + }, { "name": "bin_array_bitmap_extension", "optional": true }, { "name": "reserve_x", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { "name": "reserve_y", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { "name": "user_token_in", @@ -3537,14 +5158,23 @@ "writable": true }, { - "name": "token_x_mint" + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "token_y_mint" + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] }, { "name": "oracle", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { "name": "host_fee_in", @@ -3556,16 +5186,41 @@ "signer": true }, { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "memo_program" - }, - { - "name": "event_authority" + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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" @@ -3573,39 +5228,34 @@ ], "args": [ { - "name": "max_in_amount", + "name": "amount_in", "type": "u64" }, { - "name": "out_amount", + "name": "min_amount_out", "type": "u64" - }, - { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" - } - } } ] }, { - "name": "swap_with_price_impact2", + "name": "swap2", "discriminator": [ - 74, - 98, - 192, - 214, - 177, - 51, + 65, 75, - 51 + 63, + 76, + 235, + 91, + 91, + 136 ], "accounts": [ { "name": "lb_pair", - "writable": true + "writable": true, + "relations": [ + "bin_array_bitmap_extension" + ] }, { "name": "bin_array_bitmap_extension", @@ -3613,11 +5263,17 @@ }, { "name": "reserve_x", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { "name": "reserve_y", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { "name": "user_token_in", @@ -3628,14 +5284,23 @@ "writable": true }, { - "name": "token_x_mint" + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] }, { - "name": "token_y_mint" + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] }, { "name": "oracle", - "writable": true + "writable": true, + "relations": [ + "lb_pair" + ] }, { "name": "host_fee_in", @@ -3653,10 +5318,37 @@ "name": "token_y_program" }, { - "name": "memo_program" - }, - { - "name": "event_authority" + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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" @@ -3668,14 +5360,8 @@ "type": "u64" }, { - "name": "active_id", - "type": { - "option": "i32" - } - }, - { - "name": "max_price_impact_bps", - "type": "u16" + "name": "min_amount_out", + "type": "u64" }, { "name": "remaining_accounts_info", @@ -3688,112 +5374,1328 @@ ] }, { - "name": "close_position2", + "name": "swap_exact_out", "discriminator": [ - 174, - 90, - 35, - 115, - 186, - 40, - 147, - 226 + 250, + 73, + 101, + 33, + 38, + 207, + 75, + 184 ], "accounts": [ { - "name": "position", - "writable": true + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array_bitmap_extension" + ] }, { - "name": "sender", - "signer": true + "name": "bin_array_bitmap_extension", + "optional": true }, { - "name": "rent_receiver", - "writable": true + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "event_authority" + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] }, { - "name": "program" - } - ], - "args": [] - }, - { - "name": "update_fees_and_reward2", - "discriminator": [ - 32, - 142, - 184, - 154, - 103, - 65, - 184, - 88 - ], - "accounts": [ - { - "name": "position", + "name": "user_token_in", "writable": true }, { - "name": "lb_pair", + "name": "user_token_out", "writable": true }, { - "name": "owner", - "signer": true - } - ], - "args": [ + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, { - "name": "min_bin_id", + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "oracle", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "host_fee_in", + "writable": true, + "optional": true + }, + { + "name": "user", + "signer": true + }, + { + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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_in_amount", + "type": "u64" + }, + { + "name": "out_amount", + "type": "u64" + } + ] + }, + { + "name": "swap_exact_out2", + "discriminator": [ + 43, + 215, + 247, + 132, + 137, + 60, + 243, + 81 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "optional": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "user_token_in", + "writable": true + }, + { + "name": "user_token_out", + "writable": true + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "oracle", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "host_fee_in", + "writable": true, + "optional": true + }, + { + "name": "user", + "signer": true + }, + { + "name": "token_x_program" + }, + { + "name": "token_y_program" + }, + { + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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_in_amount", + "type": "u64" + }, + { + "name": "out_amount", + "type": "u64" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } + } + } + ] + }, + { + "name": "swap_with_price_impact", + "discriminator": [ + 56, + 173, + 230, + 208, + 173, + 228, + 156, + 205 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "optional": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "user_token_in", + "writable": true + }, + { + "name": "user_token_out", + "writable": true + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "oracle", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "host_fee_in", + "writable": true, + "optional": true + }, + { + "name": "user", + "signer": true + }, + { + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "amount_in", + "type": "u64" + }, + { + "name": "active_id", + "type": { + "option": "i32" + } + }, + { + "name": "max_price_impact_bps", + "type": "u16" + } + ] + }, + { + "name": "swap_with_price_impact2", + "discriminator": [ + 74, + 98, + 192, + 214, + 177, + 51, + 75, + 51 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "optional": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "user_token_in", + "writable": true + }, + { + "name": "user_token_out", + "writable": true + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "oracle", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "host_fee_in", + "writable": true, + "optional": true + }, + { + "name": "user", + "signer": true + }, + { + "name": "token_x_program" + }, + { + "name": "token_y_program" + }, + { + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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": "amount_in", + "type": "u64" + }, + { + "name": "active_id", + "type": { + "option": "i32" + } + }, + { + "name": "max_price_impact_bps", + "type": "u16" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } + } + } + ] + }, + { + "name": "update_base_fee_parameters", + "discriminator": [ + 75, + 168, + 223, + 161, + 16, + 195, + 3, + 47 + ], + "accounts": [ + { + "name": "lb_pair", + "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": "fee_parameter", + "type": { + "defined": { + "name": "BaseFeeParameter" + } + } + } + ] + }, + { + "name": "update_dynamic_fee_parameters", + "discriminator": [ + 92, + 161, + 46, + 246, + 255, + 189, + 22, + 22 + ], + "accounts": [ + { + "name": "lb_pair", + "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": "fee_parameter", + "type": { + "defined": { + "name": "DynamicFeeParameter" + } + } + } + ] + }, + { + "name": "update_fees_and_reward2", + "discriminator": [ + 32, + 142, + 184, + 154, + 103, + 65, + 184, + 88 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position" + ] + }, + { + "name": "owner", + "signer": true + } + ], + "args": [ + { + "name": "min_bin_id", + "type": "i32" + }, + { + "name": "max_bin_id", "type": "i32" + } + ] + }, + { + "name": "update_fees_and_rewards", + "discriminator": [ + 154, + 230, + 250, + 13, + 236, + 209, + 75, + 223 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "owner", + "signer": true + } + ], + "args": [] + }, + { + "name": "update_position_operator", + "discriminator": [ + 202, + 184, + 103, + 143, + 180, + 191, + 116, + 217 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "owner", + "signer": true, + "relations": [ + "position" + ] + }, + { + "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": "operator", + "type": "pubkey" + } + ] + }, + { + "name": "update_reward_duration", + "discriminator": [ + 138, + 174, + 196, + 169, + 213, + 235, + 254, + 107 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array" + ] }, { - "name": "max_bin_id", - "type": "i32" + "name": "admin", + "signer": true + }, + { + "name": "bin_array", + "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": "reward_index", + "type": "u64" + }, + { + "name": "new_duration", + "type": "u64" } ] }, { - "name": "close_position_if_empty", + "name": "update_reward_funder", "discriminator": [ - 59, - 124, - 212, - 118, - 91, - 152, - 110, - 157 + 211, + 28, + 48, + 32, + 215, + 160, + 35, + 23 ], "accounts": [ { - "name": "position", + "name": "lb_pair", "writable": true }, { - "name": "sender", + "name": "admin", "signer": true }, { - "name": "rent_receiver", + "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": "u64" + }, + { + "name": "new_funder", + "type": "pubkey" + } + ] + }, + { + "name": "withdraw_ineligible_reward", + "discriminator": [ + 148, + 206, + 42, + 195, + 247, + 49, + 103, + 8 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array" + ] + }, + { + "name": "reward_vault", + "writable": true + }, + { + "name": "reward_mint" + }, + { + "name": "funder_token_account", + "writable": true + }, + { + "name": "funder", + "signer": true + }, + { + "name": "bin_array", "writable": true }, { - "name": "event_authority" + "name": "token_program" + }, + { + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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": [] + "args": [ + { + "name": "reward_index", + "type": "u64" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } + } + } + ] + }, + { + "name": "withdraw_protocol_fee", + "discriminator": [ + 158, + 201, + 158, + 189, + 33, + 93, + 162, + 103 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "receiver_token_x", + "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_x_program" + }, + { + "kind": "account", + "path": "token_x_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": "receiver_token_y", + "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_y_program" + }, + { + "kind": "account", + "path": "token_y_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" + }, + { + "name": "operator", + "docs": [ + "operator" + ], + "signer": true, + "relations": [ + "claim_fee_operator" + ] + }, + { + "name": "token_x_program" + }, + { + "name": "token_y_program" + }, + { + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + } + ], + "args": [ + { + "name": "max_amount_x", + "type": "u64" + }, + { + "name": "max_amount_y", + "type": "u64" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } + } + } + ] } ], "accounts": [ + { + "name": "BinArray", + "discriminator": [ + 92, + 142, + 92, + 220, + 5, + 148, + 70, + 181 + ] + }, { "name": "BinArrayBitmapExtension", "discriminator": [ @@ -3820,6 +6722,19 @@ 150 ] }, + { + "name": "DummyZcAccount", + "discriminator": [ + 94, + 107, + 238, + 80, + 208, + 48, + 180, + 8 + ] + }, { "name": "LbPair", "discriminator": [ @@ -3847,16 +6762,29 @@ ] }, { - "name": "PresetParameter2", + "name": "Position", + "discriminator": [ + 170, + 188, + 143, + 228, + 122, + 64, + 247, + 208 + ] + }, + { + "name": "PositionV2", "discriminator": [ - 171, - 236, - 148, - 115, - 162, - 113, - 222, - 174 + 117, + 176, + 212, + 199, + 245, + 180, + 133, + 182 ] }, { @@ -3872,6 +6800,19 @@ 170 ] }, + { + "name": "PresetParameter2", + "discriminator": [ + 171, + 236, + 148, + 115, + 162, + 113, + 222, + 174 + ] + }, { "name": "TokenBadge", "discriminator": [ @@ -3887,19 +6828,6 @@ } ], "events": [ - { - "name": "CompositionFee", - "discriminator": [ - 128, - 151, - 123, - 106, - 17, - 102, - 113, - 142 - ] - }, { "name": "AddLiquidity", "discriminator": [ @@ -3914,29 +6842,29 @@ ] }, { - "name": "RemoveLiquidity", + "name": "ClaimFee", "discriminator": [ - 116, - 244, - 97, - 232, - 103, - 31, - 152, - 58 + 75, + 122, + 154, + 48, + 140, + 74, + 123, + 163 ] }, { - "name": "Swap", + "name": "ClaimFee2", "discriminator": [ - 81, - 108, - 227, - 190, - 205, - 208, - 10, - 196 + 232, + 171, + 242, + 97, + 58, + 77, + 35, + 45 ] }, { @@ -3953,107 +6881,107 @@ ] }, { - "name": "FundReward", + "name": "ClaimReward2", "discriminator": [ - 246, - 228, - 58, - 130, - 145, - 170, - 79, - 204 + 27, + 143, + 244, + 33, + 80, + 43, + 110, + 146 ] }, { - "name": "InitializeReward", + "name": "CompositionFee", "discriminator": [ - 211, - 153, - 88, - 62, - 149, - 60, - 177, - 70 + 128, + 151, + 123, + 106, + 17, + 102, + 113, + 142 ] }, { - "name": "UpdateRewardDuration", + "name": "DecreasePositionLength", "discriminator": [ - 223, - 245, - 224, - 153, - 49, - 29, - 163, - 172 + 52, + 118, + 235, + 85, + 172, + 169, + 15, + 128 ] }, { - "name": "UpdateRewardFunder", + "name": "DynamicFeeParameterUpdate", "discriminator": [ - 224, + 88, + 88, 178, - 174, - 74, - 252, - 165, - 85, - 180 + 135, + 194, + 146, + 91, + 243 ] }, { - "name": "PositionClose", + "name": "FeeParameterUpdate", "discriminator": [ - 255, - 196, - 16, - 107, - 28, - 202, - 53, - 128 + 48, + 76, + 241, + 117, + 144, + 215, + 242, + 44 ] }, { - "name": "ClaimFee", + "name": "FundReward", "discriminator": [ - 75, - 122, - 154, - 48, - 140, - 74, - 123, - 163 + 246, + 228, + 58, + 130, + 145, + 170, + 79, + 204 ] }, { - "name": "LbPairCreate", + "name": "GoToABin", "discriminator": [ - 185, - 74, - 252, - 125, - 27, - 215, - 188, - 111 + 59, + 138, + 76, + 68, + 138, + 131, + 176, + 67 ] }, { - "name": "PositionCreate", + "name": "IncreaseObservation", "discriminator": [ - 144, - 142, - 252, - 84, - 157, - 53, - 37, - 121 + 99, + 249, + 17, + 121, + 166, + 156, + 207, + 215 ] }, { @@ -4070,68 +6998,107 @@ ] }, { - "name": "DecreasePositionLength", + "name": "InitializeReward", "discriminator": [ - 52, - 118, - 235, - 85, - 172, - 169, - 15, + 211, + 153, + 88, + 62, + 149, + 60, + 177, + 70 + ] + }, + { + "name": "LbPairCreate", + "discriminator": [ + 185, + 74, + 252, + 125, + 27, + 215, + 188, + 111 + ] + }, + { + "name": "PositionClose", + "discriminator": [ + 255, + 196, + 16, + 107, + 28, + 202, + 53, 128 ] }, { - "name": "FeeParameterUpdate", + "name": "PositionCreate", "discriminator": [ - 48, - 76, - 241, - 117, 144, - 215, - 242, - 44 + 142, + 252, + 84, + 157, + 53, + 37, + 121 ] }, { - "name": "DynamicFeeParameterUpdate", + "name": "Rebalancing", "discriminator": [ - 88, - 88, - 178, - 135, - 194, - 146, + 0, + 109, + 117, + 179, + 61, 91, - 243 + 199, + 200 ] }, { - "name": "IncreaseObservation", + "name": "RemoveLiquidity", "discriminator": [ - 99, - 249, - 17, - 121, - 166, - 156, - 207, - 215 + 116, + 244, + 97, + 232, + 103, + 31, + 152, + 58 ] }, { - "name": "WithdrawIneligibleReward", + "name": "Swap", "discriminator": [ - 231, - 189, - 65, - 149, - 102, - 215, - 154, - 244 + 81, + 108, + 227, + 190, + 205, + 208, + 10, + 196 + ] + }, + { + "name": "UpdatePositionLockReleasePoint", + "discriminator": [ + 133, + 214, + 66, + 224, + 64, + 12, + 7, + 191 ] }, { @@ -4148,29 +7115,42 @@ ] }, { - "name": "UpdatePositionLockReleasePoint", + "name": "UpdateRewardDuration", "discriminator": [ - 133, - 214, - 66, + 223, + 245, 224, - 64, - 12, - 7, - 191 + 153, + 49, + 29, + 163, + 172 ] }, { - "name": "GoToABin", + "name": "UpdateRewardFunder", "discriminator": [ - 59, - 138, - 76, - 68, - 138, - 131, - 176, - 67 + 224, + 178, + 174, + 74, + 252, + 165, + 85, + 180 + ] + }, + { + "name": "WithdrawIneligibleReward", + "discriminator": [ + 231, + 189, + 65, + 149, + 102, + 215, + 154, + 244 ] } ], @@ -4589,144 +7569,213 @@ "code": 6082, "name": "NotSupportAtTheMoment", "msg": "Not support at the moment" + }, + { + "code": 6083, + "name": "InvalidRebalanceParameters", + "msg": "Invalid rebalance parameters" + }, + { + "code": 6084, + "name": "InvalidRewardAccounts", + "msg": "Invalid reward accounts" + }, + { + "code": 6085, + "name": "UndeterminedError", + "msg": "Undetermined error" + }, + { + "code": 6086, + "name": "ReallocExceedMaxLengthPerInstruction", + "msg": "Realloc exceed max length per instruction" + }, + { + "code": 6087, + "name": "InvalidBaseFeeMantissa", + "msg": "Mantissa cannot more than two significant digits" + }, + { + "code": 6088, + "name": "InvalidPositionOwner", + "msg": "Invalid position owner" + }, + { + "code": 6089, + "name": "InvalidPoolAddress", + "msg": "Invalid pool address" } ], "types": [ { - "name": "InitPresetParameters2Ix", + "name": "AccountsType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "TransferHookX" + }, + { + "name": "TransferHookY" + }, + { + "name": "TransferHookReward" + }, + { + "name": "TransferHookMultiReward", + "fields": [ + "u8" + ] + } + ] + } + }, + { + "name": "ActivationType", + "docs": [ + "Type of the activation" + ], + "repr": { + "kind": "rust" + }, + "type": { + "kind": "enum", + "variants": [ + { + "name": "Slot" + }, + { + "name": "Timestamp" + } + ] + } + }, + { + "name": "AddLiquidity", "type": { "kind": "struct", "fields": [ { - "name": "index", - "type": "u16" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "bin_step", - "docs": [ - "Bin step. Represent the price increment / decrement." - ], - "type": "u16" + "name": "from", + "type": "pubkey" }, { - "name": "base_factor", - "docs": [ - "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" - ], - "type": "u16" + "name": "position", + "type": "pubkey" }, { - "name": "filter_period", - "docs": [ - "Filter period determine high frequency trading time window." - ], - "type": "u16" + "name": "amounts", + "type": { + "array": [ + "u64", + 2 + ] + } }, { - "name": "decay_period", - "docs": [ - "Decay period determine when the volatile fee start decay / decrease." - ], - "type": "u16" + "name": "active_bin_id", + "type": "i32" + } + ] + } + }, + { + "name": "AddLiquidityParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "min_delta_id", + "type": "i32" }, { - "name": "reduction_factor", - "docs": [ - "Reduction factor controls the volatile fee rate decrement rate." - ], - "type": "u16" + "name": "max_delta_id", + "type": "i32" }, { - "name": "variable_fee_control", - "docs": [ - "Used to scale the variable fee component depending on the dynamic of the market" - ], - "type": "u32" + "name": "x0", + "type": "u64" }, { - "name": "max_volatility_accumulator", - "docs": [ - "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." - ], - "type": "u32" + "name": "y0", + "type": "u64" + }, + { + "name": "delta_x", + "type": "u64" + }, + { + "name": "delta_y", + "type": "u64" + }, + { + "name": "bit_flag", + "type": "u8" }, { - "name": "protocol_share", - "docs": [ - "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" + "name": "favor_x_in_active_id", + "type": "bool" }, { - "name": "base_fee_power_factor", - "docs": [ - "Base fee power factor" - ], - "type": "u8" + "name": "padding", + "type": { + "array": [ + "u8", + 16 + ] + } } ] } }, { - "name": "InitPresetParametersIx", + "name": "AddLiquiditySingleSidePreciseParameter", "type": { "kind": "struct", "fields": [ { - "name": "bin_step", - "docs": [ - "Bin step. Represent the price increment / decrement." - ], - "type": "u16" - }, - { - "name": "base_factor", - "docs": [ - "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" - ], - "type": "u16" - }, - { - "name": "filter_period", - "docs": [ - "Filter period determine high frequency trading time window." - ], - "type": "u16" - }, - { - "name": "decay_period", - "docs": [ - "Decay period determine when the volatile fee start decay / decrease." - ], - "type": "u16" + "name": "bins", + "type": { + "vec": { + "defined": { + "name": "CompressedBinDepositAmount" + } + } + } }, { - "name": "reduction_factor", - "docs": [ - "Reduction factor controls the volatile fee rate decrement rate." - ], - "type": "u16" - }, + "name": "decompress_multiplier", + "type": "u64" + } + ] + } + }, + { + "name": "AddLiquiditySingleSidePreciseParameter2", + "type": { + "kind": "struct", + "fields": [ { - "name": "variable_fee_control", - "docs": [ - "Used to scale the variable fee component depending on the dynamic of the market" - ], - "type": "u32" + "name": "bins", + "type": { + "vec": { + "defined": { + "name": "CompressedBinDepositAmount" + } + } + } }, { - "name": "max_volatility_accumulator", - "docs": [ - "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." - ], - "type": "u32" + "name": "decompress_multiplier", + "type": "u64" }, { - "name": "protocol_share", - "docs": [ - "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" + "name": "max_amount", + "type": "u64" } ] } @@ -4761,174 +7810,184 @@ } }, { - "name": "DynamicFeeParameter", + "name": "Bin", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "filter_period", + "name": "amount_x", "docs": [ - "Filter period determine high frequency trading time window." + "Amount of token X in the bin. This already excluded protocol fees." ], - "type": "u16" + "type": "u64" }, { - "name": "decay_period", + "name": "amount_y", "docs": [ - "Decay period determine when the volatile fee start decay / decrease." + "Amount of token Y in the bin. This already excluded protocol fees." ], - "type": "u16" + "type": "u64" }, { - "name": "reduction_factor", + "name": "price", "docs": [ - "Reduction factor controls the volatile fee rate decrement rate." + "Bin price" ], - "type": "u16" + "type": "u128" }, { - "name": "variable_fee_control", + "name": "liquidity_supply", "docs": [ - "Used to scale the variable fee component depending on the dynamic of the market" + "Liquidities of the bin. This is the same as LP mint supply. q-number" ], - "type": "u32" + "type": "u128" }, { - "name": "max_volatility_accumulator", + "name": "reward_per_token_stored", "docs": [ - "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + "reward_a_per_token_stored" ], - "type": "u32" - } - ] - } - }, - { - "name": "LiquidityParameterByStrategyOneSide", - "type": { - "kind": "struct", - "fields": [ + "type": { + "array": [ + "u128", + 2 + ] + } + }, { - "name": "amount", + "name": "fee_amount_x_per_token_stored", "docs": [ - "Amount of X token or Y token to deposit" + "Swap fee amount of token X per liquidity deposited." ], - "type": "u64" + "type": "u128" }, { - "name": "active_id", + "name": "fee_amount_y_per_token_stored", "docs": [ - "Active bin that integrator observe off-chain" + "Swap fee amount of token Y per liquidity deposited." ], - "type": "i32" + "type": "u128" }, { - "name": "max_active_bin_slippage", + "name": "amount_x_in", "docs": [ - "max active bin slippage allowed" + "Total token X swap into the bin. Only used for tracking purpose." ], - "type": "i32" + "type": "u128" }, { - "name": "strategy_parameters", + "name": "amount_y_in", "docs": [ - "strategy parameters" + "Total token Y swap into he bin. Only used for tracking purpose." ], - "type": { - "defined": { - "name": "StrategyParameters" - } - } + "type": "u128" } ] } }, { - "name": "LiquidityParameterByStrategy", + "name": "BinArray", + "docs": [ + "An account to contain a range of bin. For example: Bin 100 <-> 200.", + "For example:", + "BinArray index: 0 contains bin 0 <-> 599", + "index: 2 contains bin 600 <-> 1199, ..." + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "amount_x", - "docs": [ - "Amount of X token to deposit" - ], - "type": "u64" + "name": "index", + "type": "i64" }, { - "name": "amount_y", + "name": "version", "docs": [ - "Amount of Y token to deposit" + "Version of binArray" ], - "type": "u64" + "type": "u8" }, { - "name": "active_id", - "docs": [ - "Active bin that integrator observe off-chain" - ], - "type": "i32" + "name": "_padding", + "type": { + "array": [ + "u8", + 7 + ] + } }, { - "name": "max_active_bin_slippage", - "docs": [ - "max active bin slippage allowed" - ], - "type": "i32" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "strategy_parameters", - "docs": [ - "strategy parameters" - ], + "name": "bins", "type": { - "defined": { - "name": "StrategyParameters" - } + "array": [ + { + "defined": { + "name": "Bin" + } + }, + 70 + ] } } ] } }, { - "name": "StrategyParameters", + "name": "BinArrayBitmapExtension", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "min_bin_id", - "docs": [ - "min bin id" - ], - "type": "i32" - }, - { - "name": "max_bin_id", - "docs": [ - "max bin id" - ], - "type": "i32" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "strategy_type", + "name": "positive_bin_array_bitmap", "docs": [ - "strategy type" - ], - "type": { - "defined": { - "name": "StrategyType" - } + "Packed initialized bin array state for start_bin_index is positive" + ], + "type": { + "array": [ + { + "array": [ + "u64", + 8 + ] + }, + 12 + ] } }, { - "name": "parameteres", + "name": "negative_bin_array_bitmap", "docs": [ - "parameters" + "Packed initialized bin array state for start_bin_index is negative" ], "type": { "array": [ - "u8", - 64 + { + "array": [ + "u64", + 8 + ] + }, + 12 ] } } @@ -4936,43 +7995,30 @@ } }, { - "name": "LiquidityOneSideParameter", + "name": "BinLiquidityDistribution", "type": { "kind": "struct", "fields": [ { - "name": "amount", - "docs": [ - "Amount of X token or Y token to deposit" - ], - "type": "u64" - }, - { - "name": "active_id", + "name": "bin_id", "docs": [ - "Active bin that integrator observe off-chain" + "Define the bin ID wish to deposit to." ], "type": "i32" }, { - "name": "max_active_bin_slippage", + "name": "distribution_x", "docs": [ - "max active bin slippage allowed" + "DistributionX (or distributionY) is the percentages of amountX (or amountY) you want to add to each bin." ], - "type": "i32" + "type": "u16" }, { - "name": "bin_liquidity_dist", + "name": "distribution_y", "docs": [ - "Liquidity distribution to each bins" + "DistributionX (or distributionY) is the percentages of amountX (or amountY) you want to add to each bin." ], - "type": { - "vec": { - "defined": { - "name": "BinLiquidityDistributionByWeight" - } - } - } + "type": "u16" } ] } @@ -5000,294 +8046,209 @@ } }, { - "name": "LiquidityParameterByWeight", + "name": "BinLiquidityReduction", "type": { "kind": "struct", "fields": [ { - "name": "amount_x", - "docs": [ - "Amount of X token to deposit" - ], - "type": "u64" - }, - { - "name": "amount_y", - "docs": [ - "Amount of Y token to deposit" - ], - "type": "u64" - }, - { - "name": "active_id", - "docs": [ - "Active bin that integrator observe off-chain" - ], - "type": "i32" - }, - { - "name": "max_active_bin_slippage", - "docs": [ - "max active bin slippage allowed" - ], + "name": "bin_id", "type": "i32" }, { - "name": "bin_liquidity_dist", - "docs": [ - "Liquidity distribution to each bins" - ], - "type": { - "vec": { - "defined": { - "name": "BinLiquidityDistributionByWeight" - } - } - } + "name": "bps_to_remove", + "type": "u16" } ] } }, { - "name": "AddLiquiditySingleSidePreciseParameter", + "name": "ClaimFee", "type": { "kind": "struct", "fields": [ { - "name": "bins", - "type": { - "vec": { - "defined": { - "name": "CompressedBinDepositAmount" - } - } - } + "name": "lb_pair", + "type": "pubkey" }, { - "name": "decompress_multiplier", + "name": "position", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "fee_x", + "type": "u64" + }, + { + "name": "fee_y", "type": "u64" } ] } }, { - "name": "CompressedBinDepositAmount", + "name": "ClaimFee2", "type": { "kind": "struct", "fields": [ { - "name": "bin_id", - "type": "i32" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "amount", - "type": "u32" - } - ] - } - }, - { - "name": "BinLiquidityDistribution", - "type": { - "kind": "struct", - "fields": [ + "name": "position", + "type": "pubkey" + }, { - "name": "bin_id", - "docs": [ - "Define the bin ID wish to deposit to." - ], - "type": "i32" + "name": "owner", + "type": "pubkey" }, { - "name": "distribution_x", - "docs": [ - "DistributionX (or distributionY) is the percentages of amountX (or amountY) you want to add to each bin." - ], - "type": "u16" + "name": "fee_x", + "type": "u64" }, { - "name": "distribution_y", - "docs": [ - "DistributionX (or distributionY) is the percentages of amountX (or amountY) you want to add to each bin." - ], - "type": "u16" + "name": "fee_y", + "type": "u64" + }, + { + "name": "active_bin_id", + "type": "i32" } ] } }, { - "name": "LiquidityParameter", + "name": "ClaimFeeOperator", + "docs": [ + "Parameter that set by the protocol" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "amount_x", - "docs": [ - "Amount of X token to deposit" - ], - "type": "u64" - }, - { - "name": "amount_y", + "name": "operator", "docs": [ - "Amount of Y token to deposit" + "operator" ], - "type": "u64" + "type": "pubkey" }, { - "name": "bin_liquidity_dist", + "name": "_padding", "docs": [ - "Liquidity distribution to each bins" + "Reserve" ], "type": { - "vec": { - "defined": { - "name": "BinLiquidityDistribution" - } - } + "array": [ + "u8", + 128 + ] } } ] } }, { - "name": "CustomizableParams", + "name": "ClaimReward", "type": { "kind": "struct", "fields": [ { - "name": "active_id", - "docs": [ - "Pool price" - ], - "type": "i32" - }, - { - "name": "bin_step", - "docs": [ - "Bin step" - ], - "type": "u16" - }, - { - "name": "base_factor", - "docs": [ - "Base factor" - ], - "type": "u16" - }, - { - "name": "activation_type", - "docs": [ - "Activation type. 0 = Slot, 1 = Time. Check ActivationType enum" - ], - "type": "u8" - }, - { - "name": "has_alpha_vault", - "docs": [ - "Whether the pool has an alpha vault" - ], - "type": "bool" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "activation_point", - "docs": [ - "Decide when does the pool start trade. None = Now" - ], - "type": { - "option": "u64" - } + "name": "position", + "type": "pubkey" }, { - "name": "creator_pool_on_off_control", - "docs": [ - "Pool creator have permission to enable/disable pool with restricted program validation. Only applicable for customizable permissionless pool." - ], - "type": "bool" + "name": "owner", + "type": "pubkey" }, - { - "name": "base_fee_power_factor", - "docs": [ - "Base fee power factor" - ], - "type": "u8" + { + "name": "reward_index", + "type": "u64" }, { - "name": "padding", - "docs": [ - "Padding, for future use" - ], - "type": { - "array": [ - "u8", - 62 - ] - } + "name": "total_reward", + "type": "u64" } ] } }, { - "name": "InitPermissionPairIx", + "name": "ClaimReward2", "type": { "kind": "struct", "fields": [ { - "name": "active_id", - "type": "i32" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "bin_step", - "type": "u16" + "name": "position", + "type": "pubkey" }, { - "name": "base_factor", - "type": "u16" + "name": "owner", + "type": "pubkey" }, { - "name": "base_fee_power_factor", - "type": "u8" + "name": "reward_index", + "type": "u64" }, { - "name": "activation_type", - "type": "u8" + "name": "total_reward", + "type": "u64" }, { - "name": "protocol_share", - "type": "u16" + "name": "active_bin_id", + "type": "i32" } ] } }, { - "name": "AddLiquiditySingleSidePreciseParameter2", + "name": "CompositionFee", "type": { "kind": "struct", "fields": [ { - "name": "bins", - "type": { - "vec": { - "defined": { - "name": "CompressedBinDepositAmount" - } - } - } + "name": "from", + "type": "pubkey" }, { - "name": "decompress_multiplier", + "name": "bin_id", + "type": "i16" + }, + { + "name": "token_x_fee_amount", "type": "u64" }, { - "name": "max_amount", + "name": "token_y_fee_amount", + "type": "u64" + }, + { + "name": "protocol_token_x_fee_amount", + "type": "u64" + }, + { + "name": "protocol_token_y_fee_amount", "type": "u64" } ] } }, { - "name": "CompressedBinDepositAmount2", + "name": "CompressedBinDepositAmount", "type": { "kind": "struct", "fields": [ @@ -5303,7 +8264,7 @@ } }, { - "name": "InitializeLbPair2Params", + "name": "CustomizableParams", "type": { "kind": "struct", "fields": [ @@ -5315,239 +8276,180 @@ "type": "i32" }, { - "name": "padding", + "name": "bin_step", "docs": [ - "Padding, for future use" + "Bin step" ], - "type": { - "array": [ - "u8", - 96 - ] - } - } - ] - } - }, - { - "name": "BinLiquidityReduction", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bin_id", - "type": "i32" - }, - { - "name": "bps_to_remove", "type": "u16" - } - ] - } - }, - { - "name": "Bin", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount_x", - "docs": [ - "Amount of token X in the bin. This already excluded protocol fees." - ], - "type": "u64" }, { - "name": "amount_y", + "name": "base_factor", "docs": [ - "Amount of token Y in the bin. This already excluded protocol fees." + "Base factor" ], - "type": "u64" + "type": "u16" }, { - "name": "price", + "name": "activation_type", "docs": [ - "Bin price" + "Activation type. 0 = Slot, 1 = Time. Check ActivationType enum" ], - "type": "u128" + "type": "u8" }, { - "name": "liquidity_supply", + "name": "has_alpha_vault", "docs": [ - "Liquidities of the bin. This is the same as LP mint supply. q-number" + "Whether the pool has an alpha vault" ], - "type": "u128" + "type": "bool" }, { - "name": "reward_per_token_stored", + "name": "activation_point", "docs": [ - "reward_a_per_token_stored" + "Decide when does the pool start trade. None = Now" ], "type": { - "array": [ - "u128", - 2 - ] + "option": "u64" } }, { - "name": "fee_amount_x_per_token_stored", - "docs": [ - "Swap fee amount of token X per liquidity deposited." - ], - "type": "u128" - }, - { - "name": "fee_amount_y_per_token_stored", + "name": "creator_pool_on_off_control", "docs": [ - "Swap fee amount of token Y per liquidity deposited." + "Pool creator have permission to enable/disable pool with restricted program validation. Only applicable for customizable permissionless pool." ], - "type": "u128" + "type": "bool" }, { - "name": "amount_x_in", + "name": "base_fee_power_factor", "docs": [ - "Total token X swap into the bin. Only used for tracking purpose." + "Base fee power factor" ], - "type": "u128" + "type": "u8" }, { - "name": "amount_y_in", + "name": "padding", "docs": [ - "Total token Y swap into he bin. Only used for tracking purpose." + "Padding, for future use" ], - "type": "u128" + "type": { + "array": [ + "u8", + 62 + ] + } } ] } }, { - "name": "ProtocolFee", + "name": "DecreasePositionLength", "type": { "kind": "struct", "fields": [ { - "name": "amount_x", - "type": "u64" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "amount_y", - "type": "u64" + "name": "position", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "length_to_remove", + "type": "u16" + }, + { + "name": "side", + "type": "u8" } ] } }, { - "name": "RewardInfo", - "docs": [ - "Stores the state relevant for tracking liquidity mining rewards" - ], + "name": "DummyIx", "type": { "kind": "struct", "fields": [ { - "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": "_pair_status", + "type": { + "defined": { + "name": "PairStatus" + } + } }, { - "name": "reward_duration", - "docs": [ - "TODO check whether we need to store it in pool" - ], - "type": "u64" + "name": "_pair_type", + "type": { + "defined": { + "name": "PairType" + } + } }, { - "name": "reward_duration_end", - "docs": [ - "TODO check whether we need to store it in pool" - ], - "type": "u64" + "name": "_activation_type", + "type": { + "defined": { + "name": "ActivationType" + } + } }, { - "name": "reward_rate", - "docs": [ - "TODO check whether we need to store it in pool" - ], - "type": "u128" + "name": "_token_program_flag", + "type": { + "defined": { + "name": "TokenProgramFlags" + } + } }, { - "name": "last_update_time", - "docs": [ - "The last time reward states were updated." - ], - "type": "u64" + "name": "_resize_side", + "type": { + "defined": { + "name": "ResizeSide" + } + } }, { - "name": "cumulative_seconds_with_empty_liquidity_reward", - "docs": [ - "Accumulated seconds where when farm distribute rewards, but the bin is empty. The reward will be accumulated for next reward time window." - ], - "type": "u64" + "name": "_rounding", + "type": { + "defined": { + "name": "Rounding" + } + } } ] } }, { - "name": "Observation", + "name": "DummyZcAccount", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "cumulative_active_bin_id", - "docs": [ - "Cumulative active bin ID" - ], - "type": "i128" - }, - { - "name": "created_at", - "docs": [ - "Observation sample created timestamp" - ], - "type": "i64" - }, - { - "name": "last_updated_at", - "docs": [ - "Observation sample last updated timestamp" - ], - "type": "i64" + "name": "position_bin_data", + "type": { + "defined": { + "name": "PositionBinData" + } + } } ] } }, { - "name": "StaticParameters", - "docs": [ - "Parameter that set by the protocol" - ], + "name": "DynamicFeeParameter", "type": { "kind": "struct", "fields": [ - { - "name": "base_factor", - "docs": [ - "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" - ], - "type": "u16" - }, { "name": "filter_period", "docs": [ @@ -5582,116 +8484,63 @@ "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." ], "type": "u32" - }, - { - "name": "min_bin_id", - "docs": [ - "Min bin id supported by the pool based on the configured bin step." - ], - "type": "i32" - }, - { - "name": "max_bin_id", - "docs": [ - "Max bin id supported by the pool based on the configured bin step." - ], - "type": "i32" - }, - { - "name": "protocol_share", - "docs": [ - "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" - }, - { - "name": "base_fee_power_factor", - "docs": [ - "Base fee power factor" - ], - "type": "u8" - }, - { - "name": "padding", - "docs": [ - "Padding for bytemuck safe alignment" - ], - "type": { - "array": [ - "u8", - 5 - ] - } } ] } }, { - "name": "VariableParameters", - "docs": [ - "Parameters that changes based on dynamic of the market" - ], + "name": "DynamicFeeParameterUpdate", "type": { "kind": "struct", "fields": [ { - "name": "volatility_accumulator", - "docs": [ - "Volatility accumulator measure the number of bin crossed since reference bin ID. Normally (without filter period taken into consideration), reference bin ID is the active bin of last swap.", - "It affects the variable fee rate" - ], - "type": "u32" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "volatility_reference", + "name": "filter_period", "docs": [ - "Volatility reference is decayed volatility accumulator. It is always <= volatility_accumulator" + "Filter period determine high frequency trading time window." ], - "type": "u32" + "type": "u16" }, { - "name": "index_reference", + "name": "decay_period", "docs": [ - "Active bin id of last swap." + "Decay period determine when the volatile fee start decay / decrease." ], - "type": "i32" + "type": "u16" }, { - "name": "padding", + "name": "reduction_factor", "docs": [ - "Padding for bytemuck safe alignment" + "Reduction factor controls the volatile fee rate decrement rate." ], - "type": { - "array": [ - "u8", - 4 - ] - } + "type": "u16" }, { - "name": "last_update_timestamp", + "name": "variable_fee_control", "docs": [ - "Last timestamp the variable parameters was updated" + "Used to scale the variable fee component depending on the dynamic of the market" ], - "type": "i64" + "type": "u32" }, { - "name": "padding1", + "name": "max_volatility_accumulator", "docs": [ - "Padding for bytemuck safe alignment" + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." ], - "type": { - "array": [ - "u8", - 8 - ] - } + "type": "u32" } ] } }, { "name": "FeeInfo", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ @@ -5715,314 +8564,305 @@ } }, { - "name": "UserRewardInfo", + "name": "FeeParameterUpdate", "type": { "kind": "struct", "fields": [ { - "name": "reward_per_token_completes", - "type": { - "array": [ - "u128", - 2 - ] - } + "name": "lb_pair", + "type": "pubkey" }, { - "name": "reward_pendings", - "type": { - "array": [ - "u64", - 2 - ] - } + "name": "protocol_share", + "type": "u16" + }, + { + "name": "base_factor", + "type": "u16" } ] } }, { - "name": "RemainingAccountsSlice", + "name": "FundReward", "type": { "kind": "struct", "fields": [ { - "name": "accounts_type", - "type": { - "defined": { - "name": "AccountsType" - } - } + "name": "lb_pair", + "type": "pubkey" }, { - "name": "length", - "type": "u8" + "name": "funder", + "type": "pubkey" + }, + { + "name": "reward_index", + "type": "u64" + }, + { + "name": "amount", + "type": "u64" } ] } }, { - "name": "RemainingAccountsInfo", + "name": "GoToABin", "type": { "kind": "struct", "fields": [ { - "name": "slices", - "type": { - "vec": { - "defined": { - "name": "RemainingAccountsSlice" - } - } - } - } - ] - } - }, - { - "name": "StrategyType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "SpotOneSide" - }, - { - "name": "CurveOneSide" - }, - { - "name": "BidAskOneSide" - }, - { - "name": "SpotBalanced" - }, - { - "name": "CurveBalanced" - }, - { - "name": "BidAskBalanced" - }, - { - "name": "SpotImBalanced" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "CurveImBalanced" + "name": "from_bin_id", + "type": "i32" }, { - "name": "BidAskImBalanced" + "name": "to_bin_id", + "type": "i32" } ] } }, { - "name": "Rounding", + "name": "IncreaseObservation", "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "Up" + "name": "oracle", + "type": "pubkey" }, { - "name": "Down" + "name": "new_observation_length", + "type": "u64" } ] } }, { - "name": "ActivationType", - "docs": [ - "Type of the activation" - ], + "name": "IncreasePositionLength", "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "Slot" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "Timestamp" - } - ] - } - }, - { - "name": "LayoutVersion", - "docs": [ - "Layout version" - ], - "type": { - "kind": "enum", - "variants": [ + "name": "position", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, { - "name": "V0" + "name": "length_to_add", + "type": "u16" }, { - "name": "V1" + "name": "side", + "type": "u8" } ] } }, { - "name": "PairType", - "docs": [ - "Type of the Pair. 0 = Permissionless, 1 = Permission, 2 = CustomizablePermissionless. Putting 0 as permissionless for backward compatibility." - ], + "name": "InitPermissionPairIx", "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "Permissionless" + "name": "active_id", + "type": "i32" }, { - "name": "Permission" + "name": "bin_step", + "type": "u16" }, { - "name": "CustomizablePermissionless" + "name": "base_factor", + "type": "u16" }, { - "name": "PermissionlessV2" - } - ] - } - }, - { - "name": "PairStatus", - "docs": [ - "Pair status. 0 = Enabled, 1 = Disabled. Putting 0 as enabled for backward compatibility." - ], - "type": { - "kind": "enum", - "variants": [ + "name": "base_fee_power_factor", + "type": "u8" + }, { - "name": "Enabled" + "name": "activation_type", + "type": "u8" }, { - "name": "Disabled" + "name": "protocol_share", + "type": "u16" } ] } }, { - "name": "TokenProgramFlags", + "name": "InitPresetParameters2Ix", "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "TokenProgram" + "name": "index", + "type": "u16" }, { - "name": "TokenProgram2022" - } - ] - } - }, - { - "name": "AccountsType", - "type": { - "kind": "enum", - "variants": [ + "name": "bin_step", + "docs": [ + "Bin step. Represent the price increment / decrement." + ], + "type": "u16" + }, { - "name": "TransferHookX" + "name": "base_factor", + "docs": [ + "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" + ], + "type": "u16" }, { - "name": "TransferHookY" + "name": "filter_period", + "docs": [ + "Filter period determine high frequency trading time window." + ], + "type": "u16" }, { - "name": "TransferHookReward" + "name": "decay_period", + "docs": [ + "Decay period determine when the volatile fee start decay / decrease." + ], + "type": "u16" + }, + { + "name": "reduction_factor", + "docs": [ + "Reduction factor controls the volatile fee rate decrement rate." + ], + "type": "u16" + }, + { + "name": "variable_fee_control", + "docs": [ + "Used to scale the variable fee component depending on the dynamic of the market" + ], + "type": "u32" + }, + { + "name": "max_volatility_accumulator", + "docs": [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ], + "type": "u32" + }, + { + "name": "protocol_share", + "docs": [ + "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + ], + "type": "u16" + }, + { + "name": "base_fee_power_factor", + "docs": [ + "Base fee power factor" + ], + "type": "u8" } ] } }, { - "name": "BinArrayBitmapExtension", + "name": "InitPresetParametersIx", "type": { "kind": "struct", "fields": [ { - "name": "lb_pair", - "type": "pubkey" + "name": "bin_step", + "docs": [ + "Bin step. Represent the price increment / decrement." + ], + "type": "u16" }, { - "name": "positive_bin_array_bitmap", + "name": "base_factor", "docs": [ - "Packed initialized bin array state for start_bin_index is positive" + "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" ], - "type": { - "array": [ - { - "array": [ - "u64", - 8 - ] - }, - 12 - ] - } + "type": "u16" }, { - "name": "negative_bin_array_bitmap", + "name": "filter_period", "docs": [ - "Packed initialized bin array state for start_bin_index is negative" + "Filter period determine high frequency trading time window." ], - "type": { - "array": [ - { - "array": [ - "u64", - 8 - ] - }, - 12 - ] - } + "type": "u16" + }, + { + "name": "decay_period", + "docs": [ + "Decay period determine when the volatile fee start decay / decrease." + ], + "type": "u16" + }, + { + "name": "reduction_factor", + "docs": [ + "Reduction factor controls the volatile fee rate decrement rate." + ], + "type": "u16" + }, + { + "name": "variable_fee_control", + "docs": [ + "Used to scale the variable fee component depending on the dynamic of the market" + ], + "type": "u32" + }, + { + "name": "max_volatility_accumulator", + "docs": [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ], + "type": "u32" + }, + { + "name": "protocol_share", + "docs": [ + "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + ], + "type": "u16" } ] } }, { - "name": "BinArray", - "docs": [ - "An account to contain a range of bin. For example: Bin 100 <-> 200.", - "For example:", - "BinArray index: 0 contains bin 0 <-> 599", - "index: 2 contains bin 600 <-> 1199, ..." - ], + "name": "InitializeLbPair2Params", "type": { "kind": "struct", "fields": [ { - "name": "index", - "type": "i64" - }, - { - "name": "version", + "name": "active_id", "docs": [ - "Version of binArray" + "Pool price" ], - "type": "u8" + "type": "i32" }, { "name": "padding", + "docs": [ + "Padding, for future use" + ], "type": { "array": [ "u8", - 7 - ] - } - }, - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "bins", - "type": { - "array": [ - { - "defined": { - "name": "Bin" - } - }, - 70 + 96 ] } } @@ -6030,37 +8870,39 @@ } }, { - "name": "ClaimFeeOperator", - "docs": [ - "Parameter that set by the protocol" - ], + "name": "InitializeReward", "type": { "kind": "struct", "fields": [ { - "name": "operator", - "docs": [ - "operator" - ], + "name": "lb_pair", + "type": "pubkey" + }, + { + "name": "reward_mint", + "type": "pubkey" + }, + { + "name": "funder", "type": "pubkey" }, { - "name": "padding", - "docs": [ - "Reserve" - ], - "type": { - "array": [ - "u8", - 128 - ] - } + "name": "reward_index", + "type": "u64" + }, + { + "name": "reward_duration", + "type": "u64" } ] } }, { "name": "LbPair", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ @@ -6202,7 +9044,7 @@ } }, { - "name": "padding1", + "name": "_padding_1", "docs": [ "_padding_1, previous Fee owner, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" ], @@ -6214,137 +9056,374 @@ } }, { - "name": "reward_infos", + "name": "reward_infos", + "docs": [ + "Farming reward information" + ], + "type": { + "array": [ + { + "defined": { + "name": "RewardInfo" + } + }, + 2 + ] + } + }, + { + "name": "oracle", + "docs": [ + "Oracle pubkey" + ], + "type": "pubkey" + }, + { + "name": "bin_array_bitmap", + "docs": [ + "Packed initialized bin array state" + ], + "type": { + "array": [ + "u64", + 16 + ] + } + }, + { + "name": "last_updated_at", + "docs": [ + "Last time the pool fee parameter was updated" + ], + "type": "i64" + }, + { + "name": "_padding_2", + "docs": [ + "_padding_2, previous whitelisted_wallet, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "pre_activation_swap_address", + "docs": [ + "Address allowed to swap when the current point is greater than or equal to the pre-activation point. The pre-activation point is calculated as `activation_point - pre_activation_duration`." + ], + "type": "pubkey" + }, + { + "name": "base_key", + "docs": [ + "Base keypair. Only required for permission pair" + ], + "type": "pubkey" + }, + { + "name": "activation_point", + "docs": [ + "Time point to enable the pair. Only applicable for permission pair." + ], + "type": "u64" + }, + { + "name": "pre_activation_duration", + "docs": [ + "Duration before activation activation_point. Used to calculate pre-activation time point for pre_activation_swap_address" + ], + "type": "u64" + }, + { + "name": "_padding_3", + "docs": [ + "_padding 3 is reclaimed free space from swap_cap_deactivate_point and swap_cap_amount before, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + ], + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "_padding_4", + "docs": [ + "_padding_4, previous lock_duration, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + ], + "type": "u64" + }, + { + "name": "creator", + "docs": [ + "Pool creator" + ], + "type": "pubkey" + }, + { + "name": "token_mint_x_program_flag", + "docs": [ + "token_mint_x_program_flag" + ], + "type": "u8" + }, + { + "name": "token_mint_y_program_flag", + "docs": [ + "token_mint_y_program_flag" + ], + "type": "u8" + }, + { + "name": "_reserved", + "docs": [ + "Reserved space for future use" + ], + "type": { + "array": [ + "u8", + 22 + ] + } + } + ] + } + }, + { + "name": "LbPairCreate", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lb_pair", + "type": "pubkey" + }, + { + "name": "bin_step", + "type": "u16" + }, + { + "name": "token_x", + "type": "pubkey" + }, + { + "name": "token_y", + "type": "pubkey" + } + ] + } + }, + { + "name": "LiquidityOneSideParameter", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "docs": [ + "Amount of X token or Y token to deposit" + ], + "type": "u64" + }, + { + "name": "active_id", + "docs": [ + "Active bin that integrator observe off-chain" + ], + "type": "i32" + }, + { + "name": "max_active_bin_slippage", + "docs": [ + "max active bin slippage allowed" + ], + "type": "i32" + }, + { + "name": "bin_liquidity_dist", + "docs": [ + "Liquidity distribution to each bins" + ], + "type": { + "vec": { + "defined": { + "name": "BinLiquidityDistributionByWeight" + } + } + } + } + ] + } + }, + { + "name": "LiquidityParameter", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount_x", + "docs": [ + "Amount of X token to deposit" + ], + "type": "u64" + }, + { + "name": "amount_y", + "docs": [ + "Amount of Y token to deposit" + ], + "type": "u64" + }, + { + "name": "bin_liquidity_dist", + "docs": [ + "Liquidity distribution to each bins" + ], + "type": { + "vec": { + "defined": { + "name": "BinLiquidityDistribution" + } + } + } + } + ] + } + }, + { + "name": "LiquidityParameterByStrategy", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount_x", "docs": [ - "Farming reward information" + "Amount of X token to deposit" ], - "type": { - "array": [ - { - "defined": { - "name": "RewardInfo" - } - }, - 2 - ] - } + "type": "u64" }, { - "name": "oracle", + "name": "amount_y", "docs": [ - "Oracle pubkey" + "Amount of Y token to deposit" ], - "type": "pubkey" + "type": "u64" }, { - "name": "bin_array_bitmap", + "name": "active_id", "docs": [ - "Packed initialized bin array state" + "Active bin that integrator observe off-chain" ], - "type": { - "array": [ - "u64", - 16 - ] - } + "type": "i32" }, { - "name": "last_updated_at", + "name": "max_active_bin_slippage", "docs": [ - "Last time the pool fee parameter was updated" + "max active bin slippage allowed" ], - "type": "i64" + "type": "i32" }, { - "name": "padding2", + "name": "strategy_parameters", "docs": [ - "_padding_2, previous whitelisted_wallet, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + "strategy parameters" ], "type": { - "array": [ - "u8", - 32 - ] + "defined": { + "name": "StrategyParameters" + } } - }, - { - "name": "pre_activation_swap_address", - "docs": [ - "Address allowed to swap when the current point is greater than or equal to the pre-activation point. The pre-activation point is calculated as `activation_point - pre_activation_duration`." - ], - "type": "pubkey" - }, + } + ] + } + }, + { + "name": "LiquidityParameterByStrategyOneSide", + "type": { + "kind": "struct", + "fields": [ { - "name": "base_key", + "name": "amount", "docs": [ - "Base keypair. Only required for permission pair" + "Amount of X token or Y token to deposit" ], - "type": "pubkey" + "type": "u64" }, { - "name": "activation_point", + "name": "active_id", "docs": [ - "Time point to enable the pair. Only applicable for permission pair." + "Active bin that integrator observe off-chain" ], - "type": "u64" + "type": "i32" }, { - "name": "pre_activation_duration", + "name": "max_active_bin_slippage", "docs": [ - "Duration before activation activation_point. Used to calculate pre-activation time point for pre_activation_swap_address" + "max active bin slippage allowed" ], - "type": "u64" + "type": "i32" }, { - "name": "padding3", + "name": "strategy_parameters", "docs": [ - "_padding 3 is reclaimed free space from swap_cap_deactivate_point and swap_cap_amount before, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + "strategy parameters" ], "type": { - "array": [ - "u8", - 8 - ] + "defined": { + "name": "StrategyParameters" + } } - }, + } + ] + } + }, + { + "name": "LiquidityParameterByWeight", + "type": { + "kind": "struct", + "fields": [ { - "name": "padding4", + "name": "amount_x", "docs": [ - "_padding_4, previous lock_duration, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + "Amount of X token to deposit" ], "type": "u64" }, { - "name": "creator", + "name": "amount_y", "docs": [ - "Pool creator" + "Amount of Y token to deposit" ], - "type": "pubkey" + "type": "u64" }, { - "name": "token_mint_x_program_flag", + "name": "active_id", "docs": [ - "token_mint_x_program_flag" + "Active bin that integrator observe off-chain" ], - "type": "u8" + "type": "i32" }, { - "name": "token_mint_y_program_flag", + "name": "max_active_bin_slippage", "docs": [ - "token_mint_y_program_flag" + "max active bin slippage allowed" ], - "type": "u8" + "type": "i32" }, { - "name": "reserved", + "name": "bin_liquidity_dist", "docs": [ - "Reserved space for future use" + "Liquidity distribution to each bins" ], "type": { - "array": [ - "u8", - 22 - ] + "vec": { + "defined": { + "name": "BinLiquidityDistributionByWeight" + } + } } } ] @@ -6352,6 +9431,10 @@ }, { "name": "Oracle", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ @@ -6379,8 +9462,58 @@ ] } }, + { + "name": "PairStatus", + "docs": [ + "Pair status. 0 = Enabled, 1 = Disabled. Putting 0 as enabled for backward compatibility." + ], + "repr": { + "kind": "rust" + }, + "type": { + "kind": "enum", + "variants": [ + { + "name": "Enabled" + }, + { + "name": "Disabled" + } + ] + } + }, + { + "name": "PairType", + "docs": [ + "Type of the Pair. 0 = Permissionless, 1 = Permission, 2 = CustomizablePermissionless. Putting 0 as permissionless for backward compatibility." + ], + "repr": { + "kind": "rust" + }, + "type": { + "kind": "enum", + "variants": [ + { + "name": "Permissionless" + }, + { + "name": "Permission" + }, + { + "name": "CustomizablePermissionless" + }, + { + "name": "PermissionlessV2" + } + ] + } + }, { "name": "Position", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ @@ -6478,34 +9611,106 @@ "type": "u64" }, { - "name": "total_claimed_rewards", - "docs": [ - "Total claimed rewards" - ], - "type": { - "array": [ - "u64", - 2 - ] - } + "name": "total_claimed_rewards", + "docs": [ + "Total claimed rewards" + ], + "type": { + "array": [ + "u64", + 2 + ] + } + }, + { + "name": "_reserved", + "docs": [ + "Reserved space for future use" + ], + "type": { + "array": [ + "u8", + 160 + ] + } + } + ] + } + }, + { + "name": "PositionBinData", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "liquidity_share", + "type": "u128" + }, + { + "name": "reward_info", + "type": { + "defined": { + "name": "UserRewardInfo" + } + } + }, + { + "name": "fee_info", + "type": { + "defined": { + "name": "FeeInfo" + } + } + } + ] + } + }, + { + "name": "PositionClose", + "type": { + "kind": "struct", + "fields": [ + { + "name": "position", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "PositionCreate", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lb_pair", + "type": "pubkey" + }, + { + "name": "position", + "type": "pubkey" }, { - "name": "reserved", - "docs": [ - "Reserved space for future use" - ], - "type": { - "array": [ - "u8", - 160 - ] - } + "name": "owner", + "type": "pubkey" } ] } }, { "name": "PositionV2", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ @@ -6629,7 +9834,7 @@ "type": "u64" }, { - "name": "padding0", + "name": "_padding_0", "docs": [ "_padding_0, previous subjected_to_bootstrap_liquidity_locking, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" ], @@ -6643,7 +9848,7 @@ "type": "pubkey" }, { - "name": "reserved", + "name": "_reserved", "docs": [ "Reserved space for future use" ], @@ -6657,8 +9862,90 @@ ] } }, + { + "name": "PresetParameter", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bin_step", + "docs": [ + "Bin step. Represent the price increment / decrement." + ], + "type": "u16" + }, + { + "name": "base_factor", + "docs": [ + "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" + ], + "type": "u16" + }, + { + "name": "filter_period", + "docs": [ + "Filter period determine high frequency trading time window." + ], + "type": "u16" + }, + { + "name": "decay_period", + "docs": [ + "Decay period determine when the volatile fee start decay / decrease." + ], + "type": "u16" + }, + { + "name": "reduction_factor", + "docs": [ + "Reduction factor controls the volatile fee rate decrement rate." + ], + "type": "u16" + }, + { + "name": "variable_fee_control", + "docs": [ + "Used to scale the variable fee component depending on the dynamic of the market" + ], + "type": "u32" + }, + { + "name": "max_volatility_accumulator", + "docs": [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ], + "type": "u32" + }, + { + "name": "min_bin_id", + "docs": [ + "Min bin id supported by the pool based on the configured bin step." + ], + "type": "i32" + }, + { + "name": "max_bin_id", + "docs": [ + "Max bin id supported by the pool based on the configured bin step." + ], + "type": "i32" + }, + { + "name": "protocol_share", + "docs": [ + "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + ], + "type": "u16" + } + ] + } + }, { "name": "PresetParameter2", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ @@ -6733,14 +10020,14 @@ "type": "u8" }, { - "name": "padding0", + "name": "padding_0", "docs": [ "Padding 0 for future use" ], "type": "u8" }, { - "name": "padding1", + "name": "padding_1", "docs": [ "Padding 1 for future use" ], @@ -6755,147 +10042,247 @@ } }, { - "name": "PresetParameter", + "name": "ProtocolFee", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "bin_step", + "name": "amount_x", + "type": "u64" + }, + { + "name": "amount_y", + "type": "u64" + } + ] + } + }, + { + "name": "RebalanceLiquidityParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "active_id", "docs": [ - "Bin step. Represent the price increment / decrement." + "active id" ], - "type": "u16" + "type": "i32" }, { - "name": "base_factor", + "name": "max_active_bin_slippage", "docs": [ - "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" + "max active bin slippage allowed" ], "type": "u16" }, { - "name": "filter_period", + "name": "should_claim_fee", "docs": [ - "Filter period determine high frequency trading time window." + "a flag to indicate that whether fee should be harvested" ], - "type": "u16" + "type": "bool" }, { - "name": "decay_period", + "name": "should_claim_reward", "docs": [ - "Decay period determine when the volatile fee start decay / decrease." + "a flag to indicate that whether rewards should be harvested" ], - "type": "u16" + "type": "bool" }, { - "name": "reduction_factor", + "name": "min_withdraw_x_amount", "docs": [ - "Reduction factor controls the volatile fee rate decrement rate." + "threshold for withdraw token x" ], - "type": "u16" + "type": "u64" }, { - "name": "variable_fee_control", + "name": "max_deposit_x_amount", "docs": [ - "Used to scale the variable fee component depending on the dynamic of the market" + "threshold for deposit token x" ], - "type": "u32" + "type": "u64" }, { - "name": "max_volatility_accumulator", + "name": "min_withdraw_y_amount", "docs": [ - "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + "threshold for withdraw token y" ], - "type": "u32" + "type": "u64" }, { - "name": "min_bin_id", + "name": "max_deposit_y_amount", "docs": [ - "Min bin id supported by the pool based on the configured bin step." + "threshold for deposit token y" ], - "type": "i32" + "type": "u64" }, { - "name": "max_bin_id", + "name": "shrink_mode", "docs": [ - "Max bin id supported by the pool based on the configured bin step." + "shrink mode" ], - "type": "i32" + "type": "u8" }, { - "name": "protocol_share", + "name": "padding", "docs": [ - "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + "padding 32 bytes for future usage" ], - "type": "u16" + "type": { + "array": [ + "u8", + 31 + ] + } + }, + { + "name": "removes", + "docs": [ + "removes" + ], + "type": { + "vec": { + "defined": { + "name": "RemoveLiquidityParams" + } + } + } + }, + { + "name": "adds", + "docs": [ + "adds" + ], + "type": { + "vec": { + "defined": { + "name": "AddLiquidityParams" + } + } + } } ] } }, { - "name": "TokenBadge", - "docs": [ - "Parameter that set by the protocol" - ], + "name": "Rebalancing", "type": { "kind": "struct", "fields": [ { - "name": "token_mint", - "docs": [ - "token mint" - ], + "name": "lb_pair", + "type": "pubkey" + }, + { + "name": "position", + "type": "pubkey" + }, + { + "name": "owner", "type": "pubkey" }, { - "name": "padding", - "docs": [ - "Reserve" - ], + "name": "active_bin_id", + "type": "i32" + }, + { + "name": "x_withdrawn_amount", + "type": "u64" + }, + { + "name": "x_added_amount", + "type": "u64" + }, + { + "name": "y_withdrawn_amount", + "type": "u64" + }, + { + "name": "y_added_amount", + "type": "u64" + }, + { + "name": "x_fee_amount", + "type": "u64" + }, + { + "name": "y_fee_amount", + "type": "u64" + }, + { + "name": "old_min_id", + "type": "i32" + }, + { + "name": "old_max_id", + "type": "i32" + }, + { + "name": "new_min_id", + "type": "i32" + }, + { + "name": "new_max_id", + "type": "i32" + }, + { + "name": "rewards", + "type": { + "array": [ + "u64", + 2 + ] + } + } + ] + } + }, + { + "name": "RemainingAccountsInfo", + "type": { + "kind": "struct", + "fields": [ + { + "name": "slices", "type": { - "array": [ - "u8", - 128 - ] + "vec": { + "defined": { + "name": "RemainingAccountsSlice" + } + } } } ] } }, { - "name": "CompositionFee", + "name": "RemainingAccountsSlice", "type": { "kind": "struct", "fields": [ { - "name": "from", - "type": "pubkey" - }, - { - "name": "bin_id", - "type": "i16" - }, - { - "name": "token_x_fee_amount", - "type": "u64" - }, - { - "name": "token_y_fee_amount", - "type": "u64" - }, - { - "name": "protocol_token_x_fee_amount", - "type": "u64" + "name": "accounts_type", + "type": { + "defined": { + "name": "AccountsType" + } + } }, { - "name": "protocol_token_y_fee_amount", - "type": "u64" + "name": "length", + "type": "u8" } ] } }, { - "name": "AddLiquidity", + "name": "RemoveLiquidity", "type": { "kind": "struct", "fields": [ @@ -6928,236 +10315,322 @@ } }, { - "name": "RemoveLiquidity", + "name": "RemoveLiquidityParams", "type": { "kind": "struct", "fields": [ { - "name": "lb_pair", - "type": "pubkey" + "name": "min_bin_id", + "type": { + "option": "i32" + } }, { - "name": "from", - "type": "pubkey" + "name": "max_bin_id", + "type": { + "option": "i32" + } }, { - "name": "position", - "type": "pubkey" + "name": "bps", + "type": "u16" }, { - "name": "amounts", + "name": "padding", "type": { "array": [ - "u64", - 2 + "u8", + 16 ] } + } + ] + } + }, + { + "name": "ResizeSide", + "docs": [ + "Side of resize, 0 for lower and 1 for upper" + ], + "repr": { + "kind": "rust" + }, + "type": { + "kind": "enum", + "variants": [ + { + "name": "Lower" }, { - "name": "active_bin_id", - "type": "i32" + "name": "Upper" } ] } }, { - "name": "Swap", + "name": "RewardInfo", + "docs": [ + "Stores the state relevant for tracking liquidity mining rewards" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "lb_pair", + "name": "mint", + "docs": [ + "Reward token mint." + ], "type": "pubkey" }, { - "name": "from", + "name": "vault", + "docs": [ + "Reward vault token account." + ], "type": "pubkey" }, { - "name": "start_bin_id", - "type": "i32" - }, - { - "name": "end_bin_id", - "type": "i32" + "name": "funder", + "docs": [ + "Authority account that allows to fund rewards" + ], + "type": "pubkey" }, { - "name": "amount_in", + "name": "reward_duration", + "docs": [ + "LM reward duration in seconds." + ], "type": "u64" }, { - "name": "amount_out", + "name": "reward_duration_end", + "docs": [ + "LM reward duration end time." + ], "type": "u64" }, { - "name": "swap_for_y", - "type": "bool" - }, - { - "name": "fee", - "type": "u64" + "name": "reward_rate", + "docs": [ + "LM reward rate" + ], + "type": "u128" }, { - "name": "protocol_fee", + "name": "last_update_time", + "docs": [ + "The last time reward states were updated." + ], "type": "u64" }, { - "name": "fee_bps", - "type": "u128" - }, - { - "name": "host_fee", + "name": "cumulative_seconds_with_empty_liquidity_reward", + "docs": [ + "Accumulated seconds where when farm distribute rewards, but the bin is empty. The reward will be accumulated for next reward time window." + ], "type": "u64" } ] } }, { - "name": "ClaimReward", + "name": "Rounding", "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, + "kind": "enum", + "variants": [ { - "name": "reward_index", - "type": "u64" + "name": "Up" }, { - "name": "total_reward", - "type": "u64" + "name": "Down" } ] } }, { - "name": "FundReward", + "name": "StaticParameters", + "docs": [ + "Parameter that set by the protocol" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "lb_pair", - "type": "pubkey" + "name": "base_factor", + "docs": [ + "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" + ], + "type": "u16" }, { - "name": "funder", - "type": "pubkey" + "name": "filter_period", + "docs": [ + "Filter period determine high frequency trading time window." + ], + "type": "u16" }, { - "name": "reward_index", - "type": "u64" + "name": "decay_period", + "docs": [ + "Decay period determine when the volatile fee start decay / decrease." + ], + "type": "u16" }, { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "InitializeReward", - "type": { - "kind": "struct", - "fields": [ + "name": "reduction_factor", + "docs": [ + "Reduction factor controls the volatile fee rate decrement rate." + ], + "type": "u16" + }, { - "name": "lb_pair", - "type": "pubkey" + "name": "variable_fee_control", + "docs": [ + "Used to scale the variable fee component depending on the dynamic of the market" + ], + "type": "u32" }, { - "name": "reward_mint", - "type": "pubkey" + "name": "max_volatility_accumulator", + "docs": [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ], + "type": "u32" }, { - "name": "funder", - "type": "pubkey" + "name": "min_bin_id", + "docs": [ + "Min bin id supported by the pool based on the configured bin step." + ], + "type": "i32" }, { - "name": "reward_index", - "type": "u64" + "name": "max_bin_id", + "docs": [ + "Max bin id supported by the pool based on the configured bin step." + ], + "type": "i32" }, { - "name": "reward_duration", - "type": "u64" + "name": "protocol_share", + "docs": [ + "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + ], + "type": "u16" + }, + { + "name": "base_fee_power_factor", + "docs": [ + "Base fee power factor" + ], + "type": "u8" + }, + { + "name": "_padding", + "docs": [ + "Padding for bytemuck safe alignment" + ], + "type": { + "array": [ + "u8", + 5 + ] + } } ] } }, { - "name": "UpdateRewardDuration", + "name": "StrategyParameters", "type": { "kind": "struct", "fields": [ { - "name": "lb_pair", - "type": "pubkey" + "name": "min_bin_id", + "docs": [ + "min bin id" + ], + "type": "i32" }, { - "name": "reward_index", - "type": "u64" + "name": "max_bin_id", + "docs": [ + "max bin id" + ], + "type": "i32" }, { - "name": "old_reward_duration", - "type": "u64" + "name": "strategy_type", + "docs": [ + "strategy type" + ], + "type": { + "defined": { + "name": "StrategyType" + } + } }, { - "name": "new_reward_duration", - "type": "u64" + "name": "parameteres", + "docs": [ + "parameters" + ], + "type": { + "array": [ + "u8", + 64 + ] + } } ] } }, { - "name": "UpdateRewardFunder", + "name": "StrategyType", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "lb_pair", - "type": "pubkey" + "name": "SpotOneSide" }, { - "name": "reward_index", - "type": "u64" + "name": "CurveOneSide" }, { - "name": "old_funder", - "type": "pubkey" + "name": "BidAskOneSide" }, { - "name": "new_funder", - "type": "pubkey" - } - ] - } - }, - { - "name": "PositionClose", - "type": { - "kind": "struct", - "fields": [ + "name": "SpotBalanced" + }, { - "name": "position", - "type": "pubkey" + "name": "CurveBalanced" }, { - "name": "owner", - "type": "pubkey" + "name": "BidAskBalanced" + }, + { + "name": "SpotImBalanced" + }, + { + "name": "CurveImBalanced" + }, + { + "name": "BidAskImBalanced" } ] } }, { - "name": "ClaimFee", + "name": "Swap", "type": { "kind": "struct", "fields": [ @@ -7166,146 +10639,149 @@ "type": "pubkey" }, { - "name": "position", + "name": "from", "type": "pubkey" }, { - "name": "owner", - "type": "pubkey" + "name": "start_bin_id", + "type": "i32" }, { - "name": "fee_x", + "name": "end_bin_id", + "type": "i32" + }, + { + "name": "amount_in", "type": "u64" }, { - "name": "fee_y", + "name": "amount_out", "type": "u64" - } - ] - } - }, - { - "name": "LbPairCreate", - "type": { - "kind": "struct", - "fields": [ + }, { - "name": "lb_pair", - "type": "pubkey" + "name": "swap_for_y", + "type": "bool" }, { - "name": "bin_step", - "type": "u16" + "name": "fee", + "type": "u64" }, { - "name": "token_x", - "type": "pubkey" + "name": "protocol_fee", + "type": "u64" }, { - "name": "token_y", - "type": "pubkey" + "name": "fee_bps", + "type": "u128" + }, + { + "name": "host_fee", + "type": "u64" } ] } }, { - "name": "PositionCreate", + "name": "TokenBadge", + "docs": [ + "Parameter that set by the protocol" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "position", + "name": "token_mint", + "docs": [ + "token mint" + ], "type": "pubkey" }, { - "name": "owner", - "type": "pubkey" + "name": "_padding", + "docs": [ + "Reserve" + ], + "type": { + "array": [ + "u8", + 128 + ] + } } ] } }, { - "name": "IncreasePositionLength", + "name": "TokenProgramFlags", + "repr": { + "kind": "rust" + }, "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, + "kind": "enum", + "variants": [ { - "name": "length_to_add", - "type": "u16" + "name": "TokenProgram" }, { - "name": "side", - "type": "u8" + "name": "TokenProgram2022" } ] } }, { - "name": "DecreasePositionLength", + "name": "UpdatePositionLockReleasePoint", "type": { "kind": "struct", "fields": [ { - "name": "lb_pair", + "name": "position", "type": "pubkey" }, { - "name": "position", - "type": "pubkey" + "name": "current_point", + "type": "u64" }, { - "name": "owner", - "type": "pubkey" + "name": "new_lock_release_point", + "type": "u64" }, { - "name": "length_to_remove", - "type": "u16" + "name": "old_lock_release_point", + "type": "u64" }, { - "name": "side", - "type": "u8" + "name": "sender", + "type": "pubkey" } ] } }, { - "name": "FeeParameterUpdate", + "name": "UpdatePositionOperator", "type": { "kind": "struct", "fields": [ { - "name": "lb_pair", + "name": "position", "type": "pubkey" }, { - "name": "protocol_share", - "type": "u16" + "name": "old_operator", + "type": "pubkey" }, { - "name": "base_factor", - "type": "u16" + "name": "new_operator", + "type": "pubkey" } ] } }, { - "name": "DynamicFeeParameterUpdate", + "name": "UpdateRewardDuration", "type": { "kind": "struct", "fields": [ @@ -7314,46 +10790,22 @@ "type": "pubkey" }, { - "name": "filter_period", - "type": "u16" - }, - { - "name": "decay_period", - "type": "u16" - }, - { - "name": "reduction_factor", - "type": "u16" - }, - { - "name": "variable_fee_control", - "type": "u32" + "name": "reward_index", + "type": "u64" }, { - "name": "max_volatility_accumulator", - "type": "u32" - } - ] - } - }, - { - "name": "IncreaseObservation", - "type": { - "kind": "struct", - "fields": [ - { - "name": "oracle", - "type": "pubkey" + "name": "old_reward_duration", + "type": "u64" }, { - "name": "new_observation_length", + "name": "new_reward_duration", "type": "u64" } ] } }, { - "name": "WithdrawIneligibleReward", + "name": "UpdateRewardFunder", "type": { "kind": "struct", "fields": [ @@ -7362,66 +10814,120 @@ "type": "pubkey" }, { - "name": "reward_mint", + "name": "reward_index", + "type": "u64" + }, + { + "name": "old_funder", "type": "pubkey" }, { - "name": "amount", - "type": "u64" + "name": "new_funder", + "type": "pubkey" } ] } }, { - "name": "UpdatePositionOperator", + "name": "UserRewardInfo", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "position", - "type": "pubkey" - }, - { - "name": "old_operator", - "type": "pubkey" + "name": "reward_per_token_completes", + "type": { + "array": [ + "u128", + 2 + ] + } }, { - "name": "new_operator", - "type": "pubkey" + "name": "reward_pendings", + "type": { + "array": [ + "u64", + 2 + ] + } } ] } }, { - "name": "UpdatePositionLockReleasePoint", + "name": "VariableParameters", + "docs": [ + "Parameters that changes based on dynamic of the market" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "position", - "type": "pubkey" + "name": "volatility_accumulator", + "docs": [ + "Volatility accumulator measure the number of bin crossed since reference bin ID. Normally (without filter period taken into consideration), reference bin ID is the active bin of last swap.", + "It affects the variable fee rate" + ], + "type": "u32" }, { - "name": "current_point", - "type": "u64" + "name": "volatility_reference", + "docs": [ + "Volatility reference is decayed volatility accumulator. It is always <= volatility_accumulator" + ], + "type": "u32" }, { - "name": "new_lock_release_point", - "type": "u64" + "name": "index_reference", + "docs": [ + "Active bin id of last swap." + ], + "type": "i32" }, { - "name": "old_lock_release_point", - "type": "u64" + "name": "_padding", + "docs": [ + "Padding for bytemuck safe alignment" + ], + "type": { + "array": [ + "u8", + 4 + ] + } }, { - "name": "sender", - "type": "pubkey" + "name": "last_update_timestamp", + "docs": [ + "Last timestamp the variable parameters was updated" + ], + "type": "i64" + }, + { + "name": "_padding_1", + "docs": [ + "Padding for bytemuck safe alignment" + ], + "type": { + "array": [ + "u8", + 8 + ] + } } ] } }, { - "name": "GoToABin", + "name": "WithdrawIneligibleReward", "type": { "kind": "struct", "fields": [ @@ -7430,12 +10936,12 @@ "type": "pubkey" }, { - "name": "from_bin_id", - "type": "i32" + "name": "reward_mint", + "type": "pubkey" }, { - "name": "to_bin_id", - "type": "i32" + "name": "amount", + "type": "u64" } ] } @@ -7448,147 +10954,143 @@ "value": "10000" }, { - "name": "MAX_BIN_PER_ARRAY", - "type": { - "defined": { - "name": "usize" - } - }, - "value": "70" - }, - { - "name": "MAX_BIN_PER_POSITION", - "type": { - "defined": { - "name": "usize" - } - }, - "value": "70" + "name": "BIN_ARRAY", + "type": "bytes", + "value": "[98, 105, 110, 95, 97, 114, 114, 97, 121]" }, { - "name": "MAX_RESIZE_LENGTH", - "type": { - "defined": { - "name": "usize" - } - }, - "value": "70" + "name": "BIN_ARRAY_BITMAP_SEED", + "type": "bytes", + "value": "[98, 105, 116, 109, 97, 112]" }, { - "name": "POSITION_MAX_LENGTH", - "type": { - "defined": { - "name": "usize" - } - }, - "value": "1400" + "name": "BIN_ARRAY_BITMAP_SIZE", + "type": "i32", + "value": "512" }, { - "name": "MIN_BIN_ID", - "type": "i32", - "value": "- 443636" + "name": "CLAIM_PROTOCOL_FEE_OPERATOR", + "type": "bytes", + "value": "[99, 102, 95, 111, 112, 101, 114, 97, 116, 111, 114]" }, { - "name": "MAX_BIN_ID", - "type": "i32", - "value": "443636" + "name": "DEFAULT_BIN_PER_POSITION", + "type": "u64", + "value": "70" }, { - "name": "MAX_FEE_RATE", + "name": "EXTENSION_BINARRAY_BITMAP_SIZE", "type": "u64", - "value": "100_000_000" + "value": "12" }, { "name": "FEE_PRECISION", "type": "u64", - "value": "1_000_000_000" + "value": "1000000000" }, { - "name": "MAX_PROTOCOL_SHARE", + "name": "HOST_FEE_BPS", + "docs": [ + "Host fee. 20%" + ], "type": "u16", - "value": "2_500" + "value": "2000" }, { - "name": "HOST_FEE_BPS", + "name": "ILM_PROTOCOL_SHARE", "type": "u16", - "value": "2_000" + "value": "2000" }, { - "name": "NUM_REWARDS", - "type": { - "defined": { - "name": "usize" - } - }, - "value": "2" + "name": "MAX_BASE_FEE", + "docs": [ + "Maximum base fee, base_fee / 10^9 = fee_in_percentage" + ], + "type": "u128", + "value": "100000000" }, { - "name": "MIN_REWARD_DURATION", - "type": "u64", - "value": "1" + "name": "MAX_BIN_ID", + "docs": [ + "Maximum bin ID supported. Computed based on 1 bps." + ], + "type": "i32", + "value": "443636" }, { - "name": "MAX_REWARD_DURATION", + "name": "MAX_BIN_PER_ARRAY", "type": "u64", - "value": "31536000" + "value": "70" }, { - "name": "EXTENSION_BINARRAY_BITMAP_SIZE", - "type": { - "defined": { - "name": "usize" - } - }, - "value": "12" + "name": "MAX_BIN_STEP", + "docs": [ + "Maximum bin step" + ], + "type": "u16", + "value": "400" }, { - "name": "BIN_ARRAY_BITMAP_SIZE", - "type": "i32", - "value": "512" + "name": "MAX_FEE_RATE", + "docs": [ + "Maximum fee rate. 10%" + ], + "type": "u64", + "value": "100000000" }, { - "name": "MAX_REWARD_BIN_SPLIT", - "type": { - "defined": { - "name": "usize" - } - }, - "value": "15" + "name": "MAX_PROTOCOL_SHARE", + "docs": [ + "Maximum protocol share of the fee. 25%" + ], + "type": "u16", + "value": "2500" }, { - "name": "ILM_PROTOCOL_SHARE", - "type": "u16", - "value": "2000" + "name": "MAX_RESIZE_LENGTH", + "type": "u64", + "value": "91" }, { - "name": "PROTOCOL_SHARE", - "type": "u16", - "value": "500" + "name": "MAX_REWARD_BIN_SPLIT", + "type": "u64", + "value": "15" }, { - "name": "MAX_BIN_STEP", - "type": "u16", - "value": "400" + "name": "MAX_REWARD_DURATION", + "type": "u64", + "value": "31536000" }, { - "name": "MAX_BASE_FEE", + "name": "MINIMUM_LIQUIDITY", "type": "u128", - "value": "100_000_000" + "value": "1000000" }, { "name": "MIN_BASE_FEE", + "docs": [ + "Minimum base fee" + ], "type": "u128", - "value": "100_000" + "value": "100000" }, { - "name": "MINIMUM_LIQUIDITY", - "type": "u128", - "value": "1_000_000" + "name": "MIN_BIN_ID", + "docs": [ + "Minimum bin ID supported. Computed based on 1 bps." + ], + "type": "i32", + "value": "-443636" }, { - "name": "BIN_ARRAY", - "type": "bytes", - "value": "[98, 105, 110, 95, 97, 114, 114, 97, 121]" + "name": "MIN_REWARD_DURATION", + "type": "u64", + "value": "1" + }, + { + "name": "NUM_REWARDS", + "type": "u64", + "value": "2" }, { "name": "ORACLE", @@ -7596,9 +11098,14 @@ "value": "[111, 114, 97, 99, 108, 101]" }, { - "name": "BIN_ARRAY_BITMAP_SEED", + "name": "POSITION", "type": "bytes", - "value": "[98, 105, 116, 109, 97, 112]" + "value": "[112, 111, 115, 105, 116, 105, 111, 110]" + }, + { + "name": "POSITION_MAX_LENGTH", + "type": "u64", + "value": "1400" }, { "name": "PRESET_PARAMETER", @@ -7611,14 +11118,9 @@ "value": "[112, 114, 101, 115, 101, 116, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114, 50]" }, { - "name": "POSITION", - "type": "bytes", - "value": "[112, 111, 115, 105, 116, 105, 111, 110]" - }, - { - "name": "CLAIM_PROTOCOL_FEE_OPERATOR", - "type": "bytes", - "value": "[99, 102, 95, 111, 112, 101, 114, 97, 116, 111, 114]" + "name": "PROTOCOL_SHARE", + "type": "u16", + "value": "500" } ] } \ No newline at end of file diff --git a/libs/dlmm/Cargo.toml b/libs/dlmm/Cargo.toml new file mode 100644 index 0000000..b4ef045 --- /dev/null +++ b/libs/dlmm/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "dlmm" +version = "0.10.1" +description = "Created with Anchor" +edition = "2021" + +[dependencies] +anchor-lang = { workspace = true } +bytemuck = { workspace = true, features = ["min_const_generics"] } diff --git a/libs/dlmm/src/lib.rs b/libs/dlmm/src/lib.rs new file mode 100644 index 0000000..96d8d76 --- /dev/null +++ b/libs/dlmm/src/lib.rs @@ -0,0 +1,5 @@ +use anchor_lang::prelude::*; + +declare_program!(dlmm); + +pub use dlmm::*; diff --git a/package.json b/package.json index 51bad5c..f66f418 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,20 @@ { "license": "ISC", "scripts": { - "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint:fix": "prettier */*.ts \"*/**/*{.js,.ts}\" -w", "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check", - "test": "anchor build -- --features local && yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/*.test.ts" + "test": "anchor build -- --features local && yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/test_*/*.test.ts" }, "dependencies": { "@coral-xyz/anchor": "^0.31.1", "@solana/spl-token": "^0.4.13", "@solana/web3.js": "^1.98.2", + "babar": "^0.2.3", + "borsh": "^2.0.0", "litesvm": "^0.1.0" }, "devDependencies": { + "@meteora-ag/cp-amm-sdk": "^1.1.9", "@types/bn.js": "^5.1.0", "@types/chai": "^4.3.0", "@types/mocha": "^9.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 04bd9fd..7a02dfc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,10 +17,19 @@ importers: '@solana/web3.js': specifier: ^1.98.2 version: 1.98.2(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10) + babar: + specifier: ^0.2.3 + version: 0.2.3 + borsh: + specifier: ^2.0.0 + version: 2.0.0 litesvm: specifier: ^0.1.0 version: 0.1.0(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10) devDependencies: + '@meteora-ag/cp-amm-sdk': + specifier: ^1.1.9 + version: 1.2.3(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.8.3)(utf-8-validate@5.0.10) '@types/bn.js': specifier: ^5.1.0 version: 5.2.0 @@ -66,6 +75,9 @@ packages: peerDependencies: '@solana/web3.js': ^1.69.0 + '@meteora-ag/cp-amm-sdk@1.2.3': + resolution: {integrity: sha512-e1wo88tBe4luv/CLuKdUSVaU3ZiliU4yFQQjkP6uiawEzw827OXl60WzY0D+vitbWIad1J5u+bMepuFWv2HSdg==} + '@noble/curves@1.9.2': resolution: {integrity: sha512-HxngEd2XUcg9xi20JkwlLCtYwfoFw4JGkuZpT+WlsPD4gB/cxkvTD8fSsoAnphGZhFdZYKeQIPCuFlWPm1uE0g==} engines: {node: ^14.21.3 || >=16} @@ -225,6 +237,9 @@ packages: assertion-error@1.1.0: resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} + babar@0.2.3: + resolution: {integrity: sha512-1hmYKLj+7m5qHsJ3hosOlO7Z5BYe3E8u9u/W2BEqB4kytysuHYuGe5OIrEr7q4Zyg3y3EytFb4YrPZokYSix8g==} + balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -254,6 +269,9 @@ packages: borsh@0.7.0: resolution: {integrity: sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==} + borsh@2.0.0: + resolution: {integrity: sha512-kc9+BgR3zz9+cjbwM8ODoUB4fs3X3I5A/HtX7LZKxCLaMrEeDFoBpnhZY//DTS1VZBSs6S5v46RZRbZjRFspEg==} + brace-expansion@1.1.12: resolution: {integrity: sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==} @@ -289,6 +307,10 @@ packages: resolution: {integrity: sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw==} engines: {node: '>=4'} + chain@0.4.2: + resolution: {integrity: sha512-GtM+TlN398yBhtSp1D2dBLQomKM3Umbji3h2/NdCqAWSMKhWbjlz33j0e55rStsEZD+8OLRHuz7kWd0U3xKMDg==} + engines: {node: '>=18'} + chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} @@ -314,6 +336,10 @@ packages: color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + colors@1.4.0: + resolution: {integrity: sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==} + engines: {node: '>=0.1.90'} + commander@12.1.0: resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==} engines: {node: '>=18'} @@ -344,6 +370,9 @@ packages: resolution: {integrity: sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==} engines: {node: '>=10'} + decimal.js@10.6.0: + resolution: {integrity: sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==} + deep-eql@4.1.4: resolution: {integrity: sha512-SUwdGfqdKOwxCPeVYjwSyRpJ7Z+fhpwIAtmCUdZIWZ/YP5R9WAsyuSgpLVDi9bjWoN2LXHNss/dk3urXtdQxGg==} engines: {node: '>=6'} @@ -456,6 +485,9 @@ packages: inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} + invariant@2.2.4: + resolution: {integrity: sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==} + is-binary-path@2.1.0: resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} engines: {node: '>=8'} @@ -497,6 +529,9 @@ packages: engines: {node: '>=8'} hasBin: true + js-tokens@4.0.0: + resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + js-yaml@4.1.0: resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} hasBin: true @@ -549,6 +584,10 @@ packages: resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==} engines: {node: '>=10'} + loose-envify@1.4.0: + resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} + hasBin: true + loupe@2.3.7: resolution: {integrity: sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==} @@ -853,6 +892,22 @@ snapshots: bn.js: 5.2.2 buffer-layout: 1.2.2 + '@meteora-ag/cp-amm-sdk@1.2.3(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.8.3)(utf-8-validate@5.0.10)': + dependencies: + '@coral-xyz/anchor': 0.31.1(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10) + '@solana/spl-token': 0.4.13(@solana/web3.js@1.98.2(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10))(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.8.3)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.98.2(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10) + '@types/bn.js': 5.2.0 + chain: 0.4.2 + decimal.js: 10.6.0 + invariant: 2.2.4 + transitivePeerDependencies: + - bufferutil + - encoding + - fastestsmallesttextencoderdecoder + - typescript + - utf-8-validate + '@noble/curves@1.9.2': dependencies: '@noble/hashes': 1.8.0 @@ -1060,6 +1115,10 @@ snapshots: assertion-error@1.1.0: {} + babar@0.2.3: + dependencies: + colors: 1.4.0 + balanced-match@1.0.2: {} base-x@3.0.11: @@ -1088,6 +1147,8 @@ snapshots: bs58: 4.0.1 text-encoding-utf-8: 1.0.2 + borsh@2.0.0: {} + brace-expansion@1.1.12: dependencies: balanced-match: 1.0.2 @@ -1129,6 +1190,8 @@ snapshots: pathval: 1.1.1 type-detect: 4.1.0 + chain@0.4.2: {} + chalk@4.1.2: dependencies: ansi-styles: 4.3.0 @@ -1164,6 +1227,8 @@ snapshots: color-name@1.1.4: {} + colors@1.4.0: {} + commander@12.1.0: {} commander@14.0.0: {} @@ -1186,6 +1251,8 @@ snapshots: decamelize@4.0.0: {} + decimal.js@10.6.0: {} + deep-eql@4.1.4: dependencies: type-detect: 4.1.0 @@ -1272,6 +1339,10 @@ snapshots: inherits@2.0.4: {} + invariant@2.2.4: + dependencies: + loose-envify: 1.4.0 + is-binary-path@2.1.0: dependencies: binary-extensions: 2.3.0 @@ -1314,6 +1385,8 @@ snapshots: - bufferutil - utf-8-validate + js-tokens@4.0.0: {} + js-yaml@4.1.0: dependencies: argparse: 2.0.1 @@ -1365,6 +1438,10 @@ snapshots: chalk: 4.1.2 is-unicode-supported: 0.1.0 + loose-envify@1.4.0: + dependencies: + js-tokens: 4.0.0 + loupe@2.3.7: dependencies: get-func-name: 2.0.2 diff --git a/programs/zap/Cargo.toml b/programs/zap/Cargo.toml index 4e887b0..580a97b 100644 --- a/programs/zap/Cargo.toml +++ b/programs/zap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zap" -version = "0.1.0" +version = "0.2.0" description = "Created with Anchor" edition = "2021" @@ -21,3 +21,10 @@ idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"] [dependencies] anchor-lang = { workspace = true, features = ["event-cpi"] } anchor-spl = { workspace = true, features = [] } +bytemuck = { workspace = true, features = ["derive", "min_const_generics"] } +dlmm = { path = "../../libs/dlmm" } +damm-v2 = { git = "https://github.com/MeteoraAg/damm-v2", features = [ + "cpi", + "no-entrypoint", +], rev = "689a3264484799d833c505523f4ff4e4990690aa", package="cp-amm" } +ruint = "1.3.0" \ No newline at end of file diff --git a/programs/zap/src/constants.rs b/programs/zap/src/constants.rs index 623592a..1b33c6e 100644 --- a/programs/zap/src/constants.rs +++ b/programs/zap/src/constants.rs @@ -1,25 +1,40 @@ +use anchor_lang::constant; use anchor_lang::{prelude::Pubkey, pubkey}; +#[constant] pub const DAMM_V2: Pubkey = pubkey!("cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"); // https://github.com/MeteoraAg/zap-program/blob/main/idls/damm_v2.json#L3512-L3521 +#[constant] pub const DAMM_V2_SWAP_DISC: [u8; 8] = [248, 198, 158, 145, 225, 117, 135, 200]; +#[constant] pub const JUP_V6: Pubkey = pubkey!("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"); // https://github.com/MeteoraAg/zap-program/blob/main/idls/jup_v6.json#L14-L23 +#[constant] pub const JUP_V6_ROUTE_DISC: [u8; 8] = [229, 23, 203, 151, 122, 227, 173, 42]; // https://github.com/MeteoraAg/zap-program/blob/main/idls/jup_v6.json#L257-L266 +#[constant] pub const JUP_V6_SHARED_ACCOUNT_ROUTE_DISC: [u8; 8] = [193, 32, 155, 51, 65, 214, 156, 129]; -#[cfg(not(feature = "local"))] pub const DLMM: Pubkey = pubkey!("LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo"); // https://github.com/MeteoraAg/zap-program/blob/main/idls/dlmm.json#L3413-L3422 +#[constant] pub const DLMM_SWAP2_DISC: [u8; 8] = [65, 75, 63, 76, 235, 91, 91, 136]; -#[cfg(feature = "local")] -pub const DLMM: Pubkey = pubkey!("LbVRzDTvBDEcrthxfZ4RL6yiq3uZw8bS6MwtdY6UhFQ"); +#[constant] pub const WHITELISTED_AMM_PROGRAMS: [(Pubkey, [u8; 8]); 4] = [ (DAMM_V2, DAMM_V2_SWAP_DISC), (DLMM, DLMM_SWAP2_DISC), (JUP_V6, JUP_V6_ROUTE_DISC), (JUP_V6, JUP_V6_SHARED_ACCOUNT_ROUTE_DISC), ]; + +#[constant] +pub const MAX_BASIS_POINT: u16 = 10_000; + +pub mod seeds { + use anchor_lang::constant; + + #[constant] + pub const USER_LEDGER_PREFIX: &[u8] = b"user_ledger"; +} diff --git a/programs/zap/src/error.rs b/programs/zap/src/error.rs index 1e51af3..27e1fa7 100644 --- a/programs/zap/src/error.rs +++ b/programs/zap/src/error.rs @@ -19,4 +19,16 @@ pub enum ZapError { #[msg("Amm program is not supported")] AmmIsNotSupported, + + #[msg("Position is not empty")] + InvalidPosition, + + #[msg("Exceeded slippage tolerance")] + ExceededSlippage, + + #[msg("Invalid dlmm zap in parameters")] + InvalidDlmmZapInParameters, + + #[msg("Unsupported fee mode")] + UnsupportedFeeMode, } diff --git a/programs/zap/src/instructions/ix_zap_in_damm_v2.rs b/programs/zap/src/instructions/ix_zap_in_damm_v2.rs new file mode 100644 index 0000000..06544f8 --- /dev/null +++ b/programs/zap/src/instructions/ix_zap_in_damm_v2.rs @@ -0,0 +1,291 @@ +use anchor_lang::prelude::*; +use anchor_spl::{token::accessor, token_interface::Mint}; +use damm_v2::{ + activation_handler::ActivationHandler, params::swap::TradeDirection, state::Pool, + AddLiquidityParameters, SwapMode, SwapParameters2, +}; + +use crate::{ + damm_v2_utils::{calculate_swap_amount, get_price_change_bps}, + error::ZapError, + new_transfer_fee_calculator, UserLedger, +}; + +#[derive(Accounts)] +pub struct ZapInDammv2Ctx<'info> { + #[account(mut, has_one = owner)] + pub ledger: AccountLoader<'info, UserLedger>, + + #[account(mut)] + pub pool: AccountLoader<'info, Pool>, + + /// CHECK: pool_authority, will be checked when we call function in damm v2 + pub pool_authority: UncheckedAccount<'info>, + + /// CHECK: position, will be checked when we call function in damm v2 + #[account(mut)] + pub position: UncheckedAccount<'info>, + + /// CHECK: The user token a account + #[account(mut)] + pub token_a_account: UncheckedAccount<'info>, + + /// CHECK: The user token b account + #[account(mut)] + pub token_b_account: UncheckedAccount<'info>, + + /// CHECK: token_a_vault, will be checked when we call function in damm v2 + #[account(mut)] + pub token_a_vault: UncheckedAccount<'info>, + + /// CHECK: token_b_vault, will be checked when we call function in damm v2 + #[account(mut)] + pub token_b_vault: UncheckedAccount<'info>, + + /// CHECK: The mint of token a + pub token_a_mint: InterfaceAccount<'info, Mint>, + + /// CHECK: The mint of token b + pub token_b_mint: InterfaceAccount<'info, Mint>, + + /// CHECK: position_nft_account, will be checked when we call function in damm v2 + pub position_nft_account: UncheckedAccount<'info>, + + /// owner of position + pub owner: Signer<'info>, + + /// CHECK: Token a program + pub token_a_program: UncheckedAccount<'info>, + + /// CHECK: Token b program + pub token_b_program: UncheckedAccount<'info>, + + pub damm_program: Program<'info, damm_v2::program::CpAmm>, + + /// CHECK: damm event authority, will be check in damm v2 functions + pub damm_event_authority: UncheckedAccount<'info>, +} + +impl<'info> ZapInDammv2Ctx<'info> { + fn swap(&self, amount: u64, trade_direction: TradeDirection) -> Result<()> { + let (input_token_account, output_token_account) = if trade_direction == TradeDirection::AtoB + { + ( + self.token_a_account.to_account_info(), + self.token_b_account.to_account_info(), + ) + } else { + ( + self.token_b_account.to_account_info(), + self.token_a_account.to_account_info(), + ) + }; + damm_v2::cpi::swap2( + CpiContext::new( + self.damm_program.to_account_info(), + damm_v2::cpi::accounts::SwapCtx { + pool_authority: self.pool_authority.to_account_info(), + input_token_account, + output_token_account, + pool: self.pool.to_account_info(), + token_a_vault: self.token_a_vault.to_account_info(), + token_b_vault: self.token_b_vault.to_account_info(), + token_a_mint: self.token_a_mint.to_account_info(), + token_b_mint: self.token_b_mint.to_account_info(), + token_a_program: self.token_a_program.to_account_info(), + token_b_program: self.token_b_program.to_account_info(), + event_authority: self.damm_event_authority.to_account_info(), + program: self.damm_program.to_account_info(), + payer: self.owner.to_account_info(), + referral_token_account: None, // TODO check whether it should be some(damm_program) + }, + ), + SwapParameters2 { + amount_0: amount, + amount_1: 0, + swap_mode: SwapMode::ExactIn.into(), + }, + )?; + Ok(()) + } + + fn add_liquidity(&self, liquidity: u128) -> Result<()> { + damm_v2::cpi::add_liquidity( + CpiContext::new( + self.damm_program.to_account_info(), + damm_v2::cpi::accounts::AddLiquidityCtx { + pool: self.pool.to_account_info(), + position: self.position.to_account_info(), + token_a_account: self.token_a_account.to_account_info(), + token_b_account: self.token_b_account.to_account_info(), + token_a_vault: self.token_a_vault.to_account_info(), + token_b_vault: self.token_b_vault.to_account_info(), + token_a_mint: self.token_a_mint.to_account_info(), + token_b_mint: self.token_b_mint.to_account_info(), + position_nft_account: self.position_nft_account.to_account_info(), + owner: self.owner.to_account_info(), + token_a_program: self.token_a_program.to_account_info(), + token_b_program: self.token_b_program.to_account_info(), + event_authority: self.damm_event_authority.to_account_info(), + program: self.damm_program.to_account_info(), + }, + ), + AddLiquidityParameters { + liquidity_delta: liquidity, + token_a_amount_threshold: u64::MAX, + token_b_amount_threshold: u64::MAX, + }, + )?; + Ok(()) + } +} + +pub fn handle_zap_in_damm_v2( + ctx: Context, + pre_sqrt_price: u128, // sqrt price user observe in local + max_sqrt_price_change_bps: u32, // max sqrt price change after swap +) -> Result<()> { + let mut ledger = ctx.accounts.ledger.load_mut()?; + let max_deposit_a_amount = ledger.amount_a; + let max_deposit_b_amount = ledger.amount_b; + // 1. we add liquidity firstly, so later if we need swap, user could get some fees back + let pool = ctx.accounts.pool.load()?; + let token_a_account_ai = ctx.accounts.token_a_account.to_account_info(); + let token_b_account_ai = ctx.accounts.token_b_account.to_account_info(); + + let token_a_transfer_fee_calculator = new_transfer_fee_calculator(&ctx.accounts.token_a_mint)?; + let token_b_transfer_fee_calculator = new_transfer_fee_calculator(&ctx.accounts.token_b_mint)?; + + let user_amount_a_1 = accessor::amount(&token_a_account_ai)?; + let user_amount_b_1 = accessor::amount(&token_b_account_ai)?; + + let (liquidity, trade_direction) = ledger.get_liquidity_from_amounts_and_trade_direction( + &token_a_transfer_fee_calculator, + &token_b_transfer_fee_calculator, + pool.sqrt_price, + pool.sqrt_min_price, + pool.sqrt_max_price, + )?; + + drop(pool); + + if liquidity > 0 { + ctx.accounts.add_liquidity(liquidity)?; + } + + // 2. We check if user is still having some balance left, we will swap before they could add remaining liquidity + let user_amount_a_2 = accessor::amount(&token_a_account_ai)?; + let user_amount_b_2 = accessor::amount(&token_b_account_ai)?; + + ledger.update_ledger_balances( + user_amount_a_1, + user_amount_a_2, + user_amount_b_1, + user_amount_b_2, + )?; + + let remaining_amount = if trade_direction == TradeDirection::AtoB { + ledger.amount_a + } else { + ledger.amount_b + }; + + if remaining_amount > 0 { + let pool = ctx.accounts.pool.load()?; + let current_point = ActivationHandler::get_current_point(pool.activation_type)?; + let swap_result = calculate_swap_amount( + &pool, + &token_a_transfer_fee_calculator, + &token_b_transfer_fee_calculator, + remaining_amount, + trade_direction, + current_point, + ); + match swap_result { + Ok((swap_in_amount, swap_out_amount)) => { + if swap_in_amount == 0 || swap_out_amount == 0 { + msg!( + "max_deposit_amounts: {} {}, remaining_amounts: {} {}, swap_amounts: {} {}", + max_deposit_a_amount, + max_deposit_b_amount, + ledger.amount_a, + ledger.amount_b, + swap_in_amount, + swap_out_amount + ); + return Ok(()); // no need to swap, just return + } + drop(pool); + ctx.accounts.swap(swap_in_amount, trade_direction)?; + } + Err(err) => { + // if calculation fail, we just skip swap and add liquidity with remaining amount + msg!("Calculate swap amount error: {:?}", err); + msg!( + "max_deposit_amounts: {} {}, remaining_amounts: {} {}", + max_deposit_a_amount, + max_deposit_b_amount, + ledger.amount_a, + ledger.amount_b + ); + return Ok(()); + } + } + } + + // validate pool price after swap + let pool = ctx.accounts.pool.load()?; + let post_sqrt_price = pool.sqrt_price; + // validate price change + let sqrt_price_change_bps = get_price_change_bps(pre_sqrt_price, post_sqrt_price)?; + require!( + sqrt_price_change_bps <= max_sqrt_price_change_bps, + ZapError::ExceededSlippage + ); + + // 3. Do final add liquidity + // reload balance + let user_amount_a_3 = accessor::amount(&token_a_account_ai)?; + let user_amount_b_3 = accessor::amount(&token_b_account_ai)?; + + ledger.update_ledger_balances( + user_amount_a_2, + user_amount_a_3, + user_amount_b_2, + user_amount_b_3, + )?; + + let (liquidity, _trade_direction) = ledger.get_liquidity_from_amounts_and_trade_direction( + &token_a_transfer_fee_calculator, + &token_b_transfer_fee_calculator, + pool.sqrt_price, + pool.sqrt_min_price, + pool.sqrt_max_price, + )?; + + if liquidity > 0 { + drop(pool); + ctx.accounts.add_liquidity(liquidity)?; + } + + let user_amount_a_4 = accessor::amount(&token_a_account_ai)?; + let user_amount_b_4 = accessor::amount(&token_b_account_ai)?; + + ledger.update_ledger_balances( + user_amount_a_3, + user_amount_a_4, + user_amount_b_3, + user_amount_b_4, + )?; + + // log will be truncated, shouldn't rely on that + msg!( + "max_deposit_amounts: {} {}, remaining_amounts: {} {}", + max_deposit_a_amount, + max_deposit_b_amount, + ledger.amount_a, + ledger.amount_b + ); + + Ok(()) +} diff --git a/programs/zap/src/instructions/ledger_instructions.rs b/programs/zap/src/instructions/ledger_instructions.rs new file mode 100644 index 0000000..20d4652 --- /dev/null +++ b/programs/zap/src/instructions/ledger_instructions.rs @@ -0,0 +1,104 @@ +use anchor_lang::prelude::*; +use anchor_spl::token::accessor; + +use crate::{constants::seeds::USER_LEDGER_PREFIX, UserLedger}; + +#[derive(Accounts)] +pub struct InitializeLedgerAccountCtx<'info> { + #[account( + init, + seeds = [USER_LEDGER_PREFIX.as_ref(), owner.key().as_ref()], + payer = payer, + space = 8 + UserLedger::INIT_SPACE, + bump + )] + pub ledger: AccountLoader<'info, UserLedger>, + + pub owner: Signer<'info>, + + #[account(mut)] + pub payer: Signer<'info>, + + pub system_program: Program<'info, System>, +} + +pub fn handle_initialize_ledger_account(ctx: Context) -> Result<()> { + let mut ledger = ctx.accounts.ledger.load_init()?; + ledger.owner = ctx.accounts.owner.key(); + Ok(()) +} + +#[derive(Accounts)] +pub struct CloseLedgerAccountCtx<'info> { + #[account( + mut, + has_one = owner, + close = rent_receiver, + )] + pub ledger: AccountLoader<'info, UserLedger>, + + pub owner: Signer<'info>, + + #[account(mut)] + pub rent_receiver: Signer<'info>, +} + +pub fn handle_close_ledger_account(_ctx: Context) -> Result<()> { + // anchor do everything + Ok(()) +} + +#[derive(Accounts)] +pub struct SetLedgerBalanceCtx<'info> { + #[account( + mut, has_one = owner + )] + pub ledger: AccountLoader<'info, UserLedger>, + + pub owner: Signer<'info>, +} + +pub fn handle_set_ledger_balance( + ctx: Context, + amount: u64, + is_token_a: bool, +) -> Result<()> { + let mut ledger = ctx.accounts.ledger.load_mut()?; + if is_token_a { + ledger.amount_a = amount + } else { + ledger.amount_b = amount + } + Ok(()) +} + +#[derive(Accounts)] +pub struct UpdateLedgerBalanceAfterSwapCtx<'info> { + #[account( + mut, has_one = owner + )] + pub ledger: AccountLoader<'info, UserLedger>, + + /// CHECK: user must send correct user account + pub token_account: UncheckedAccount<'info>, + + pub owner: Signer<'info>, +} + +pub fn handle_update_ledger_balance_after_swap( + ctx: Context, + pre_source_token_balance: u64, + max_transfer_amount: u64, + is_token_a: bool, +) -> Result<()> { + let current_token_balance = accessor::amount(&ctx.accounts.token_account.to_account_info())?; + let delta_balance: u64 = current_token_balance.saturating_sub(pre_source_token_balance); + let amount = delta_balance.min(max_transfer_amount); + let mut ledger = ctx.accounts.ledger.load_mut()?; + if is_token_a { + ledger.amount_a = amount + } else { + ledger.amount_b = amount + } + Ok(()) +} diff --git a/programs/zap/src/instructions/mod.rs b/programs/zap/src/instructions/mod.rs index bf7b400..d44346d 100644 --- a/programs/zap/src/instructions/mod.rs +++ b/programs/zap/src/instructions/mod.rs @@ -1,2 +1,8 @@ pub mod ix_zap_out; pub use ix_zap_out::*; +pub mod ix_zap_in_damm_v2; +pub use ix_zap_in_damm_v2::*; +pub mod ledger_instructions; +pub use ledger_instructions::*; +pub mod zap_in_dlmm; +pub use zap_in_dlmm::*; diff --git a/programs/zap/src/instructions/zap_in_dlmm/ix_zap_in_dlmm_for_initialized_position.rs b/programs/zap/src/instructions/zap_in_dlmm/ix_zap_in_dlmm_for_initialized_position.rs new file mode 100644 index 0000000..e9be5c6 --- /dev/null +++ b/programs/zap/src/instructions/zap_in_dlmm/ix_zap_in_dlmm_for_initialized_position.rs @@ -0,0 +1,205 @@ +use anchor_lang::prelude::*; +use anchor_spl::{token::accessor, token_interface::Mint}; +use damm_v2::token::calculate_transfer_fee_excluded_amount; +use dlmm::{ + accounts::LbPair, + types::{AddLiquidityParams, RebalanceLiquidityParams, RemainingAccountsInfo}, +}; + +use crate::{ + error::ZapError, StrategyType, UnparsedAddLiquidityParams, UserLedger, ZapInRebalancingParams, +}; + +#[derive(Accounts)] +pub struct ZapInDlmmForInitializedPositionCtx<'info> { + #[account(mut, has_one = owner)] + pub ledger: AccountLoader<'info, UserLedger>, + + /// lb pair + #[account(mut)] + pub lb_pair: AccountLoader<'info, LbPair>, + + /// CHECK: will be validated in dlmm program + #[account(mut)] + pub position: UncheckedAccount<'info>, + + /// CHECK: will be validated in dlmm program + #[account(mut)] + pub bin_array_bitmap_extension: Option>, + + /// CHECK: will be validated in dlmm program + #[account(mut)] + pub user_token_x: UncheckedAccount<'info>, + + /// CHECK: will be validated in dlmm program + #[account(mut)] + pub user_token_y: UncheckedAccount<'info>, + + /// CHECK: will be validated in dlmm program + #[account(mut)] + pub reserve_x: UncheckedAccount<'info>, + + /// CHECK: will be validated in dlmm program + #[account(mut)] + pub reserve_y: UncheckedAccount<'info>, + + pub token_x_mint: InterfaceAccount<'info, Mint>, + pub token_y_mint: InterfaceAccount<'info, Mint>, + + pub dlmm_program: Program<'info, dlmm::program::LbClmm>, + + /// owner of position + pub owner: Signer<'info>, + + #[account(mut)] + pub rent_payer: Signer<'info>, + + /// CHECK: will be validated in dlmm program + pub token_x_program: UncheckedAccount<'info>, + + /// CHECK: will be validated in dlmm program + pub token_y_program: UncheckedAccount<'info>, + + /// CHECK: will be validated in dlmm program + pub memo_program: UncheckedAccount<'info>, + /// CHECK: will be validated in dlmm program + pub system_program: UncheckedAccount<'info>, + /// CHECK: will be validated in dlmm program + pub dlmm_event_authority: UncheckedAccount<'info>, +} + +pub fn handle_zap_in_dlmm_for_initialized_position<'c: 'info, 'info>( + ctx: Context<'_, '_, 'c, 'info, ZapInDlmmForInitializedPositionCtx<'info>>, + active_id: i32, + max_active_bin_slippage: u16, + min_delta_id: i32, + max_delta_id: i32, + favor_x_in_active_id: bool, + strategy: StrategyType, + remaining_accounts_info: RemainingAccountsInfo, +) -> Result<()> { + let mut ledger = ctx.accounts.ledger.load_mut()?; + let max_deposit_x_amount = ledger.amount_a; + let max_deposit_y_amount = ledger.amount_b; + let token_x_account_ai = ctx.accounts.user_token_x.to_account_info(); + let token_y_account_ai = ctx.accounts.user_token_y.to_account_info(); + let pre_user_amount_x = accessor::amount(&token_x_account_ai)?; + let pre_user_amount_y = accessor::amount(&token_y_account_ai)?; + + let amount_x = + calculate_transfer_fee_excluded_amount(&ctx.accounts.token_x_mint, max_deposit_x_amount)? + .amount; + let amount_y = + calculate_transfer_fee_excluded_amount(&ctx.accounts.token_y_mint, max_deposit_y_amount)? + .amount; + + let lb_pair = ctx.accounts.lb_pair.load()?; + + let lb_pair_active_id = lb_pair.active_id; + + let params = ZapInRebalancingParams { + amount_x, + amount_y, + active_id: lb_pair_active_id, + bin_step: lb_pair.bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + strategy, + }; + + require!( + min_delta_id <= max_delta_id, + ZapError::InvalidDlmmZapInParameters + ); + + let UnparsedAddLiquidityParams { + x0, + y0, + delta_x, + delta_y, + bit_flag, + } = params.get_rebalancing_params()?; + + let params = RebalanceLiquidityParams { + active_id, + max_active_bin_slippage, + should_claim_fee: false, + should_claim_reward: false, + min_withdraw_x_amount: 0, + max_deposit_x_amount, + min_withdraw_y_amount: 0, + max_deposit_y_amount, + shrink_mode: 0, // we allow to shrink in both side + padding: [0; 31], + removes: vec![], + adds: vec![AddLiquidityParams { + min_delta_id, + max_delta_id, + x0, + y0, + delta_x, + delta_y, + favor_x_in_active_id, + bit_flag, + ..Default::default() + }], + }; + + drop(lb_pair); + + let bin_array_bitmap_extension = if let Some(value) = &ctx.accounts.bin_array_bitmap_extension { + Some(value.to_account_info()) + } else { + None + }; + + dlmm::cpi::rebalance_liquidity( + CpiContext::new( + ctx.accounts.dlmm_program.to_account_info(), + dlmm::cpi::accounts::RebalanceLiquidity { + position: ctx.accounts.position.to_account_info(), + lb_pair: ctx.accounts.lb_pair.to_account_info(), + bin_array_bitmap_extension, + owner: ctx.accounts.owner.to_account_info(), + user_token_x: ctx.accounts.user_token_x.to_account_info(), + user_token_y: ctx.accounts.user_token_y.to_account_info(), + reserve_x: ctx.accounts.reserve_x.to_account_info(), + reserve_y: ctx.accounts.reserve_y.to_account_info(), + token_x_mint: ctx.accounts.token_x_mint.to_account_info(), + token_y_mint: ctx.accounts.token_y_mint.to_account_info(), + rent_payer: ctx.accounts.rent_payer.to_account_info(), + token_x_program: ctx.accounts.token_x_program.to_account_info(), + token_y_program: ctx.accounts.token_y_program.to_account_info(), + memo_program: ctx.accounts.memo_program.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + program: ctx.accounts.dlmm_program.to_account_info(), + event_authority: ctx.accounts.dlmm_event_authority.to_account_info(), + }, + ) + .with_remaining_accounts(ctx.remaining_accounts.to_vec()), + params, + remaining_accounts_info, + )?; + + let post_user_amount_x = accessor::amount(&token_x_account_ai)?; + let post_user_amount_y = accessor::amount(&token_y_account_ai)?; + + ledger.update_ledger_balances( + pre_user_amount_x, + post_user_amount_x, + pre_user_amount_y, + post_user_amount_y, + )?; + + // log will be truncated, shouldn't rely on that + msg!( + "max_deposit_amounts: {} {}, remaining_amounts: {} {}", + max_deposit_x_amount, + max_deposit_y_amount, + ledger.amount_a, + ledger.amount_b + ); + + Ok(()) +} diff --git a/programs/zap/src/instructions/zap_in_dlmm/ix_zap_in_dlmm_for_uninitialized_position.rs b/programs/zap/src/instructions/zap_in_dlmm/ix_zap_in_dlmm_for_uninitialized_position.rs new file mode 100644 index 0000000..ce5593d --- /dev/null +++ b/programs/zap/src/instructions/zap_in_dlmm/ix_zap_in_dlmm_for_uninitialized_position.rs @@ -0,0 +1,247 @@ +use crate::{ + error::ZapError, StrategyType, UnparsedAddLiquidityParams, UserLedger, ZapInRebalancingParams, +}; +use anchor_lang::prelude::*; +use anchor_spl::{token::accessor, token_interface::Mint}; +use damm_v2::{safe_math::SafeMath, token::calculate_transfer_fee_excluded_amount}; +use dlmm::{ + accounts::LbPair, + types::{AddLiquidityParams, RebalanceLiquidityParams, RemainingAccountsInfo}, +}; + +#[derive(Accounts)] +pub struct ZapInDlmmForUnintializedPositionCtx<'info> { + #[account(mut, has_one = owner)] + pub ledger: AccountLoader<'info, UserLedger>, + + /// lb pair + #[account(mut)] + pub lb_pair: AccountLoader<'info, LbPair>, + + /// user position + /// Check it is different from owner to avoid user to pass owner address wrongly + #[account(mut, constraint = position.key.ne(owner.key) && position.key.ne(rent_payer.key))] + pub position: Signer<'info>, + + /// CHECK: will be validated in dlmm program + #[account(mut)] + pub bin_array_bitmap_extension: Option>, + + /// CHECK: will be validated in dlmm program + #[account(mut)] + pub user_token_x: UncheckedAccount<'info>, + + /// CHECK: will be validated in dlmm program + #[account(mut)] + pub user_token_y: UncheckedAccount<'info>, + + /// CHECK: will be validated in dlmm program + #[account(mut)] + pub reserve_x: UncheckedAccount<'info>, + + /// CHECK: will be validated in dlmm program + #[account(mut)] + pub reserve_y: UncheckedAccount<'info>, + + pub token_x_mint: InterfaceAccount<'info, Mint>, + pub token_y_mint: InterfaceAccount<'info, Mint>, + + pub dlmm_program: Program<'info, dlmm::program::LbClmm>, + + /// owner of position + pub owner: Signer<'info>, + + #[account(mut)] + pub rent_payer: Signer<'info>, + + /// CHECK: will be validated in dlmm program + pub token_x_program: UncheckedAccount<'info>, + + /// CHECK: will be validated in dlmm program + pub token_y_program: UncheckedAccount<'info>, + + /// CHECK: will be validated in dlmm program + pub memo_program: UncheckedAccount<'info>, + + /// CHECK: will be validated in dlmm program + pub system_program: UncheckedAccount<'info>, + + /// CHECK: will be validated in dlmm program + pub dlmm_event_authority: UncheckedAccount<'info>, +} + +impl<'info> ZapInDlmmForUnintializedPositionCtx<'info> { + fn initialize_position(&self, lower_bin_id: i32, width: i32) -> Result<()> { + dlmm::cpi::initialize_position2( + CpiContext::new( + self.dlmm_program.to_account_info(), + dlmm::cpi::accounts::InitializePosition2 { + payer: self.rent_payer.to_account_info(), + position: self.position.to_account_info(), + lb_pair: self.lb_pair.to_account_info(), + owner: self.owner.to_account_info(), + program: self.dlmm_program.to_account_info(), + event_authority: self.dlmm_event_authority.to_account_info(), + system_program: self.system_program.to_account_info(), + }, + ), + lower_bin_id, + width, + )?; + Ok(()) + } +} + +pub fn handle_zap_in_dlmm_for_uninitialized_position<'c: 'info, 'info>( + ctx: Context<'_, '_, 'c, 'info, ZapInDlmmForUnintializedPositionCtx<'info>>, + min_delta_id: i32, + max_delta_id: i32, + active_id: i32, + max_active_bin_slippage: u16, + favor_x_in_active_id: bool, + strategy: StrategyType, + remaining_accounts_info: RemainingAccountsInfo, +) -> Result<()> { + let mut ledger = ctx.accounts.ledger.load_mut()?; + let max_deposit_x_amount = ledger.amount_a; + let max_deposit_y_amount = ledger.amount_b; + + let token_x_account_ai = ctx.accounts.user_token_x.to_account_info(); + let token_y_account_ai = ctx.accounts.user_token_y.to_account_info(); + let pre_user_amount_x = accessor::amount(&token_x_account_ai)?; + let pre_user_amount_y = accessor::amount(&token_y_account_ai)?; + + let lb_pair = ctx.accounts.lb_pair.load()?; + + // create position wth bin_delta in left side, and bin_delta in right side + let lower_bin_id = lb_pair.active_id.safe_add(min_delta_id)?; + let width = max_delta_id.safe_sub(min_delta_id)?.safe_add(1)?; + + // check the position is not initialized yet + require!( + ctx.accounts.position.owner.eq(&Pubkey::default()) && ctx.accounts.position.data_is_empty(), + ZapError::InvalidPosition + ); + + // initialize position + drop(lb_pair); + ctx.accounts.initialize_position(lower_bin_id, width)?; + + // rebalancing + // TODO refactor to save more code with endpoint zap in dlmm for initialized position + let lb_pair = ctx.accounts.lb_pair.load()?; + let lb_pair_active_id = lb_pair.active_id; + + let amount_x = + calculate_transfer_fee_excluded_amount(&ctx.accounts.token_x_mint, max_deposit_x_amount)? + .amount; + let amount_y = + calculate_transfer_fee_excluded_amount(&ctx.accounts.token_y_mint, max_deposit_y_amount)? + .amount; + + let params = ZapInRebalancingParams { + amount_x, + amount_y, + active_id: lb_pair_active_id, + bin_step: lb_pair.bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + strategy, + }; + + require!( + min_delta_id <= max_delta_id, + ZapError::InvalidDlmmZapInParameters + ); + + let UnparsedAddLiquidityParams { + x0, + y0, + delta_x, + delta_y, + bit_flag, + } = params.get_rebalancing_params()?; + + let params = RebalanceLiquidityParams { + active_id, + max_active_bin_slippage, + should_claim_fee: false, + should_claim_reward: false, + min_withdraw_x_amount: 0, + max_deposit_x_amount, + min_withdraw_y_amount: 0, + max_deposit_y_amount, + shrink_mode: 0, // we allow to shrink in both side + padding: [0; 31], + removes: vec![], + adds: vec![AddLiquidityParams { + min_delta_id, + max_delta_id, + x0, + y0, + delta_x, + delta_y, + favor_x_in_active_id, + bit_flag, + ..Default::default() + }], + }; + + drop(lb_pair); + + let bin_array_bitmap_extension = if let Some(value) = &ctx.accounts.bin_array_bitmap_extension { + Some(value.to_account_info()) + } else { + None + }; + + dlmm::cpi::rebalance_liquidity( + CpiContext::new( + ctx.accounts.dlmm_program.to_account_info(), + dlmm::cpi::accounts::RebalanceLiquidity { + position: ctx.accounts.position.to_account_info(), + lb_pair: ctx.accounts.lb_pair.to_account_info(), + bin_array_bitmap_extension, + owner: ctx.accounts.owner.to_account_info(), + user_token_x: ctx.accounts.user_token_x.to_account_info(), + user_token_y: ctx.accounts.user_token_y.to_account_info(), + reserve_x: ctx.accounts.reserve_x.to_account_info(), + reserve_y: ctx.accounts.reserve_y.to_account_info(), + token_x_mint: ctx.accounts.token_x_mint.to_account_info(), + token_y_mint: ctx.accounts.token_y_mint.to_account_info(), + rent_payer: ctx.accounts.rent_payer.to_account_info(), + token_x_program: ctx.accounts.token_x_program.to_account_info(), + token_y_program: ctx.accounts.token_y_program.to_account_info(), + memo_program: ctx.accounts.memo_program.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + program: ctx.accounts.dlmm_program.to_account_info(), + event_authority: ctx.accounts.dlmm_event_authority.to_account_info(), + }, + ) + .with_remaining_accounts(ctx.remaining_accounts.to_vec()), + params, + remaining_accounts_info, + )?; + + let post_user_amount_x = accessor::amount(&token_x_account_ai)?; + let post_user_amount_y = accessor::amount(&token_y_account_ai)?; + + ledger.update_ledger_balances( + pre_user_amount_x, + post_user_amount_x, + pre_user_amount_y, + post_user_amount_y, + )?; + + // log will be truncated, shouldn't rely on that + msg!( + "max_deposit_amounts: {} {}, remaining_amounts: {} {}", + max_deposit_x_amount, + max_deposit_y_amount, + ledger.amount_a, + ledger.amount_b + ); + + Ok(()) +} diff --git a/programs/zap/src/instructions/zap_in_dlmm/mod.rs b/programs/zap/src/instructions/zap_in_dlmm/mod.rs new file mode 100644 index 0000000..3675dd3 --- /dev/null +++ b/programs/zap/src/instructions/zap_in_dlmm/mod.rs @@ -0,0 +1,7 @@ +// deposit in initialized position +pub mod ix_zap_in_dlmm_for_initialized_position; +pub use ix_zap_in_dlmm_for_initialized_position::*; + +// create position and deposit in position +pub mod ix_zap_in_dlmm_for_uninitialized_position; +pub use ix_zap_in_dlmm_for_uninitialized_position::*; diff --git a/programs/zap/src/lib.rs b/programs/zap/src/lib.rs index 9a42432..e998a23 100644 --- a/programs/zap/src/lib.rs +++ b/programs/zap/src/lib.rs @@ -8,19 +8,104 @@ pub mod constants; pub mod error; pub mod math; pub use math::*; - +pub mod state; +#[cfg(test)] pub mod tests; - +pub use state::*; +pub mod utils; +use dlmm::types::RemainingAccountsInfo; +pub use utils::*; declare_id!("zapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMiz"); #[program] pub mod zap { use super::*; - pub fn zap_out<'c: 'info, 'info>( ctx: Context<'_, '_, 'c, 'info, ZapOutCtx<'info>>, params: ZapOutParameters, ) -> Result<()> { instructions::handle_zap_out(ctx, ¶ms) } + + pub fn initialize_ledger_account(ctx: Context) -> Result<()> { + instructions::handle_initialize_ledger_account(ctx) + } + + pub fn close_ledger_account(ctx: Context) -> Result<()> { + instructions::handle_close_ledger_account(ctx) + } + + pub fn set_ledger_balance( + ctx: Context, + amount: u64, + is_token_a: bool, + ) -> Result<()> { + instructions::handle_set_ledger_balance(ctx, amount, is_token_a) + } + + pub fn update_ledger_balance_after_swap( + ctx: Context, + pre_source_token_balance: u64, + max_transfer_amount: u64, + is_token_a: bool, + ) -> Result<()> { + instructions::handle_update_ledger_balance_after_swap( + ctx, + pre_source_token_balance, + max_transfer_amount, + is_token_a, + ) + } + + pub fn zap_in_damm_v2( + ctx: Context, + pre_sqrt_price: u128, + max_sqrt_price_change_bps: u32, + ) -> Result<()> { + instructions::handle_zap_in_damm_v2(ctx, pre_sqrt_price, max_sqrt_price_change_bps) + } + + pub fn zap_in_dlmm_for_initialized_position<'c: 'info, 'info>( + ctx: Context<'_, '_, 'c, 'info, ZapInDlmmForInitializedPositionCtx<'info>>, + active_id: i32, + min_delta_id: i32, + max_delta_id: i32, + max_active_bin_slippage: u16, + favor_x_in_active_id: bool, + strategy: StrategyType, + remaining_accounts_info: RemainingAccountsInfo, + ) -> Result<()> { + instructions::handle_zap_in_dlmm_for_initialized_position( + ctx, + active_id, + max_active_bin_slippage, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + strategy, + remaining_accounts_info, + ) + } + + pub fn zap_in_dlmm_for_uninitialized_position<'c: 'info, 'info>( + ctx: Context<'_, '_, 'c, 'info, ZapInDlmmForUnintializedPositionCtx<'info>>, + min_delta_id: i32, + max_delta_id: i32, + active_id: i32, + max_active_bin_slippage: u16, + favor_x_in_active_id: bool, + strategy: StrategyType, + remaining_accounts_info: RemainingAccountsInfo, + ) -> Result<()> { + instructions::handle_zap_in_dlmm_for_uninitialized_position( + ctx, + min_delta_id, + max_delta_id, + active_id, + max_active_bin_slippage, + favor_x_in_active_id, + strategy, + remaining_accounts_info, + ) + } } diff --git a/programs/zap/src/math/mod.rs b/programs/zap/src/math/mod.rs index b145058..f5baee5 100644 --- a/programs/zap/src/math/mod.rs +++ b/programs/zap/src/math/mod.rs @@ -1 +1,2 @@ +pub mod price_math; pub mod safe_math; diff --git a/programs/zap/src/math/price_math.rs b/programs/zap/src/math/price_math.rs new file mode 100644 index 0000000..158ad51 --- /dev/null +++ b/programs/zap/src/math/price_math.rs @@ -0,0 +1,199 @@ +use anchor_lang::prelude::*; + +use crate::{constants::MAX_BASIS_POINT, error::ZapError, safe_math::SafeMath}; + +// Number of bits to scale. This will decide the position of the radix point. +const SCALE_OFFSET: u8 = 64; + +// 1.0000... representation of 64x64 +pub const ONE: u128 = 1u128 << SCALE_OFFSET; +const MAX_EXPONENTIAL: u32 = 0x80000; // 1048576 + +// In Trader Joe, the active_id need to be shifted by 2 ** 23 to get the actual ID. +// The reason is because they mint LP for each bin based on active_id using ERC1155, which the ID do not support negative + +/// Calculate price based on the given bin id. Eg: 1.0001 ^ 5555. The returned value is in Q64.64 +pub fn get_price_from_id(active_id: i32, bin_step: u16) -> Result { + let base = get_price_base_factor(bin_step)?; + pow(base, active_id).ok_or_else(|| ZapError::MathOverflow.into()) +} + +// get price base factor +pub fn get_price_base_factor(bin_step: u16) -> Result { + // Make bin_step into Q64x64, and divided by MAX_BASIS_POINT. If bin_step = 1, we get 0.0001 in Q64x64 + let bps = u128::from(bin_step) + .safe_shl(SCALE_OFFSET.into())? + .safe_div(MAX_BASIS_POINT as u128)?; + // Add 1 to bps, we get 1.0001 in Q64.64 + let base = ONE.safe_add(bps)?; + Ok(base) +} + +pub fn pow(base: u128, exp: i32) -> Option { + // https://doc.rust-lang.org/std/primitive.i32.html#method.abs + // The absolute value of i32::MIN cannot be represented as an i32, and attempting to calculate it will cause an overflow. + if exp == i32::MIN { + return None; + } + + // If exponent is negative. We will invert the result later by 1 / base^exp.abs() + let mut invert = exp.is_negative(); + + // When exponential is 0, result will always be 1 + if exp == 0 { + return Some(1u128 << 64); + } + + // Make the exponential positive. Which will compute the result later by 1 / base^exp + let exp: u32 = if invert { exp.abs() as u32 } else { exp as u32 }; + + // No point to continue the calculation as it will overflow the maximum value Q64.64 can support + if exp >= MAX_EXPONENTIAL { + return None; + } + + let mut squared_base = base; + let mut result = ONE; + + // When multiply the base twice, the number of bits double from 128 -> 256, which overflow. + // The trick here is to inverse the calculation, which make the upper 64 bits (number bits) to be 0s. + // For example: + // let base = 1.001, exp = 5 + // let neg = 1 / (1.001 ^ 5) + // Inverse the neg: 1 / neg + // By using a calculator, you will find out that 1.001^5 == 1 / (1 / 1.001^5) + if squared_base >= result { + // This inverse the base: 1 / base + squared_base = u128::MAX.checked_div(squared_base)?; + // If exponent is negative, the above already inverted the result. Therefore, at the end of the function, we do not need to invert again. + invert = !invert; + } + + // The following code is equivalent to looping through each binary value of the exponential. + // As explained in MAX_EXPONENTIAL, 19 exponential bits are enough to covert the full bin price. + // Therefore, there will be 19 if statements, which similar to the following pseudo code. + /* + let mut result = 1; + while exponential > 0 { + if exponential & 1 > 0 { + result *= base; + } + base *= base; + exponential >>= 1; + } + */ + + // From right to left + // squared_base = 1 * base^1 + // 1st bit is 1 + if exp & 0x1 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + // squared_base = base^2 + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + // 2nd bit is 1 + if exp & 0x2 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + // Example: + // If the base is 1.001, exponential is 3. Binary form of 3 is ..0011. The last 2 1's bit fulfill the above 2 bitwise condition. + // The result will be 1 * base^1 * base^2 == base^3. The process continues until reach the 20th bit + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x4 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x8 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x10 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x20 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x40 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x80 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x100 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x200 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x400 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x800 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x1000 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x2000 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x4000 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x8000 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x10000 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x20000 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + squared_base = (squared_base.checked_mul(squared_base)?) >> SCALE_OFFSET; + if exp & 0x40000 > 0 { + result = (result.checked_mul(squared_base)?) >> SCALE_OFFSET + } + + // Stop here as the next is 20th bit, which > MAX_EXPONENTIAL + if result == 0 { + return None; + } + + if invert { + result = u128::MAX.checked_div(result)?; + } + + Some(result) +} diff --git a/programs/zap/src/math/safe_math.rs b/programs/zap/src/math/safe_math.rs index aedd21e..71421e5 100644 --- a/programs/zap/src/math/safe_math.rs +++ b/programs/zap/src/math/safe_math.rs @@ -1,8 +1,8 @@ +use crate::error::ZapError; use anchor_lang::solana_program::msg; +use ruint::aliases::{U192, U256, U512}; use std::panic::Location; -use crate::error::ZapError; - pub trait SafeMath: Sized { fn safe_add(self, rhs: Self) -> Result; fn safe_mul(self, rhs: Self) -> Result; @@ -110,6 +110,10 @@ checked_impl!(u64, u32); checked_impl!(i64, u32); checked_impl!(usize, u32); checked_impl!(u128, u32); +checked_impl!(i128, u32); +checked_impl!(U192, usize); +checked_impl!(U256, usize); +checked_impl!(U512, usize); #[cfg(test)] mod tests { diff --git a/programs/zap/src/state/mod.rs b/programs/zap/src/state/mod.rs new file mode 100644 index 0000000..0c2216b --- /dev/null +++ b/programs/zap/src/state/mod.rs @@ -0,0 +1,2 @@ +pub mod user_ledger; +pub use user_ledger::*; diff --git a/programs/zap/src/state/user_ledger.rs b/programs/zap/src/state/user_ledger.rs new file mode 100644 index 0000000..ff64336 --- /dev/null +++ b/programs/zap/src/state/user_ledger.rs @@ -0,0 +1,64 @@ +use crate::{ + damm_v2_utils::{get_liquidity_from_amount_a, get_liquidity_from_amount_b}, + error::ZapError, + math::safe_math::SafeMath, + TransferFeeCalculator, +}; +use anchor_lang::prelude::*; +use damm_v2::params::swap::TradeDirection; + +#[account(zero_copy)] +#[derive(InitSpace, Debug, Default)] +pub struct UserLedger { + pub owner: Pubkey, + pub amount_a: u64, // amount_x in DLMM + pub amount_b: u64, // amount_y in DLMM +} + +impl UserLedger { + pub fn update_ledger_balances( + &mut self, + pre_amount_a: u64, + post_amount_a: u64, + pre_amount_b: u64, + post_amount_b: u64, + ) -> Result<()> { + self.amount_a = u128::from(self.amount_a) + .safe_add(post_amount_a.into())? + .safe_sub(pre_amount_a.into())? + .try_into() + .map_err(|_| ZapError::MathOverflow)?; + + self.amount_b = u128::from(self.amount_b) + .safe_add(post_amount_b.into())? + .safe_sub(pre_amount_b.into())? + .try_into() + .map_err(|_| ZapError::MathOverflow)?; + Ok(()) + } + // only needed for damm v2 function + pub fn get_liquidity_from_amounts_and_trade_direction<'info>( + &self, + token_a_transfer_fee_calculator: &TransferFeeCalculator, + token_b_transfer_fee_calculator: &TransferFeeCalculator, + sqrt_price: u128, + min_sqrt_price: u128, + max_sqrt_price: u128, + ) -> Result<(u128, TradeDirection)> { + let amount_a = token_a_transfer_fee_calculator + .calculate_transfer_fee_excluded_amount(self.amount_a)? + .amount; + let amount_b = token_b_transfer_fee_calculator + .calculate_transfer_fee_excluded_amount(self.amount_b)? + .amount; + let liquidity_from_a = get_liquidity_from_amount_a(amount_a, max_sqrt_price, sqrt_price)?; + let liquidity_from_b = get_liquidity_from_amount_b(amount_b, min_sqrt_price, sqrt_price)?; + if liquidity_from_a > liquidity_from_b { + // a is surplus, so we need to swap AtoB + Ok((liquidity_from_b, TradeDirection::AtoB)) + } else { + // b is surplus, so we need to swap BtoA + Ok((liquidity_from_a, TradeDirection::BtoA)) + } + } +} diff --git a/programs/zap/src/tests/dlmm_rebalancing_tests/bid_ask_strategy_tests.rs b/programs/zap/src/tests/dlmm_rebalancing_tests/bid_ask_strategy_tests.rs new file mode 100644 index 0000000..0c69324 --- /dev/null +++ b/programs/zap/src/tests/dlmm_rebalancing_tests/bid_ask_strategy_tests.rs @@ -0,0 +1,392 @@ +use crate::{ + tests::dlmm_rebalancing_tests::utils::{ + assert_diff_amount, build_add_liquidity_params, get_bin_add_liquidity, + get_liquidity_distribution, get_total_amount, AmountInBin, + }, + StrategyType, +}; + +const STRATEGY: StrategyType = StrategyType::BidAsk; + +#[test] +fn test_strategy_only_ask_side_single_bin() { + let active_id = 100; + let bin_step = 100; + let total_amount_x = 100_000_000; + let min_delta_id = 100; + let max_delta_id = 100; + let favor_x_in_active_id = true; + + let params = build_add_liquidity_params( + total_amount_x, + 0, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + let amount_in_bin = &amount_in_bins[0]; + + let diff = total_amount_x - amount_in_bin.amount_x; + assert_eq!(diff, 12); +} + +#[test] +fn test_strategy_only_bid_side_favour_x() { + let active_id = 100; + let bin_step = 10; + let total_amount_y = 100_000_000; + let min_delta_id = -100; + let max_delta_id = -1; + let favor_x_in_active_id = true; + + let params = build_add_liquidity_params( + 0, + total_amount_y, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + // println!("amount_in_bins {:#?}", amount_in_bins); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + } + if bin_id == active_id { + assert!(amount_y == 0); + } + if bin_id > active_id { + assert!(amount_x > 0); + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("{:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + assert_eq!(amount_x, 0); + println!("amount_y {}", amount_y); + assert_eq!(amount_y <= total_amount_y, true); + assert_diff_amount(total_amount_y, amount_y, 10); // less than 10bps +} + +#[test] +fn test_strategy_only_bid_side_favor_y() { + let active_id = 100; + let bin_step = 10; + let total_amount_y = 100_000_000; + let min_delta_id = -100; + let max_delta_id = 0; + let favor_x_in_active_id = false; + + let params = build_add_liquidity_params( + 0, + total_amount_y, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + // println!("amount_in_bins {:#?}", amount_in_bins); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + } + if bin_id == active_id { + assert!(amount_x == 0); + } + if bin_id > active_id { + assert!(amount_x > 0); + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("{:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + assert_eq!(amount_x, 0); + println!("amount_y {}", amount_y); + assert_eq!(amount_y <= total_amount_y, true); + assert_diff_amount(total_amount_y, amount_y, 10); // less than 10bps +} + +#[test] +fn test_strategy_only_ask_side_favour_y() { + let active_id = 100; + let bin_step = 10; + let total_amount_x = 100_000_000; + let min_delta_id = 1; + let max_delta_id = 100; + let favor_x_in_active_id = false; + + let params = build_add_liquidity_params( + total_amount_x, + 0, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + assert!(amount_y > 0); + } + if bin_id == active_id { + assert!(amount_y == 0); + } + if bin_id > active_id { + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("liquidity distribution {:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + assert_eq!(amount_y, 0); + println!("amount_x {}", amount_x); + assert_eq!(amount_x <= total_amount_x, true); + assert_diff_amount(total_amount_x, amount_x, 10); // less than 10bps +} + +#[test] +fn test_strategy_only_ask_side_favour_x() { + let active_id = 100; + let bin_step = 10; + let total_amount_x = 100_000_000; + let min_delta_id = 1; + let max_delta_id = 100; + let favor_x_in_active_id = true; + + let params = build_add_liquidity_params( + total_amount_x, + 0, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + assert!(amount_y > 0); + } + if bin_id == active_id { + assert!(amount_y == 0); + } + if bin_id > active_id { + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("liquidity distribution {:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + assert_eq!(amount_y, 0); + println!("amount_x {}", amount_x); + assert_eq!(amount_x <= total_amount_x, true); + assert_diff_amount(total_amount_x, amount_x, 10); // less than 10bps +} + +#[test] +fn test_strategy_both_sides_favor_y() { + let active_id = 100; + let bin_step = 10; + let total_amount_x = 100_000_000; + let total_amount_y = 200_000_000; + let min_delta_id = -50; + let max_delta_id = 100; + let favor_x_in_active_id = false; + + let params = build_add_liquidity_params( + total_amount_x, + total_amount_y, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + } + if bin_id == active_id { + assert!(amount_x == 0); + } + if bin_id > active_id { + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("{:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + println!("amount_x {} amount_y {}", amount_x, amount_y); + assert_eq!(amount_x <= total_amount_x, true); + assert_eq!(amount_y <= total_amount_y, true); + + assert_diff_amount(total_amount_x, amount_x, 10); // less than 10bps + assert_diff_amount(total_amount_y, amount_y, 10); // less than 10bps +} + +#[test] +fn test_strategy_both_sides_favor_x() { + let active_id = 100; + let bin_step = 10; + let total_amount_x = 100_000_000; + let total_amount_y = 200_000_000; + let min_delta_id = -50; + let max_delta_id = 100; + let favor_x_in_active_id = true; + + let params = build_add_liquidity_params( + total_amount_x, + total_amount_y, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + } + if bin_id == active_id { + assert!(amount_y == 0); + } + if bin_id > active_id { + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("{:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + println!("amount_x {} amount_y {}", amount_x, amount_y); + assert_eq!(amount_x <= total_amount_x, true); + assert_eq!(amount_y <= total_amount_y, true); + + assert_diff_amount(total_amount_x, amount_x, 10); // less than 10bps + assert_diff_amount(total_amount_y, amount_y, 10); // less than 10bps +} diff --git a/programs/zap/src/tests/dlmm_rebalancing_tests/curve_strategy_tests.rs b/programs/zap/src/tests/dlmm_rebalancing_tests/curve_strategy_tests.rs new file mode 100644 index 0000000..97bddc7 --- /dev/null +++ b/programs/zap/src/tests/dlmm_rebalancing_tests/curve_strategy_tests.rs @@ -0,0 +1,393 @@ +use crate::{ + tests::dlmm_rebalancing_tests::utils::{ + assert_diff_amount, build_add_liquidity_params, get_bin_add_liquidity, + get_liquidity_distribution, get_total_amount, AmountInBin, + }, + StrategyType, +}; + +const STRATEGY: StrategyType = StrategyType::Curve; + +#[test] +fn test_strategy_only_ask_side_single_bin() { + let active_id = 100; + let bin_step = 100; + let total_amount_x = 100_000_000; + let min_delta_id = 100; + let max_delta_id = 100; + let favor_x_in_active_id = true; + + let params = build_add_liquidity_params( + total_amount_x, + 0, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + let amount_in_bin = &amount_in_bins[0]; + + let diff = total_amount_x - amount_in_bin.amount_x; + assert_eq!(diff, 1); +} + +#[test] +fn test_strategy_only_bid_side_favour_x() { + let active_id = 100; + let bin_step = 10; + let total_amount_y = 100_000_000; + let min_delta_id = -100; + let max_delta_id = -1; + let favor_x_in_active_id = true; + + let params = build_add_liquidity_params( + 0, + total_amount_y, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + // println!("amount_in_bins {:#?}", amount_in_bins); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + } + if bin_id == active_id { + assert!(amount_y == 0); + } + if bin_id > active_id { + assert!(amount_x > 0); + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("{:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + assert_eq!(amount_x, 0); + println!("amount_y {}", amount_y); + assert_eq!(amount_y <= total_amount_y, true); + assert_diff_amount(total_amount_y, amount_y, 10); // less than 10bps +} + +#[test] +fn test_strategy_only_bid_side_favor_y() { + let active_id = 100; + let bin_step = 10; + let total_amount_y = 100_000_000; + let min_delta_id = -100; + let max_delta_id = 0; + let favor_x_in_active_id = false; + + let params = build_add_liquidity_params( + 0, + total_amount_y, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + // println!("amount_in_bins {:#?}", amount_in_bins); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + } + if bin_id == active_id { + assert!(amount_x == 0); + assert!(amount_y > 0); + } + if bin_id > active_id { + assert!(amount_x > 0); + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("{:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + assert_eq!(amount_x, 0); + println!("amount_y {}", amount_y); + assert_eq!(amount_y <= total_amount_y, true); + assert_diff_amount(total_amount_y, amount_y, 10); // less than 10bps +} + +#[test] +fn test_strategy_only_ask_side_favour_y() { + let active_id = 100; + let bin_step = 10; + let total_amount_x = 100_000_000; + let min_delta_id = 1; + let max_delta_id = 100; + let favor_x_in_active_id = false; + + let params = build_add_liquidity_params( + total_amount_x, + 0, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + assert!(amount_y > 0); + } + if bin_id == active_id { + assert!(amount_y == 0); + } + if bin_id > active_id { + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("liquidity distribution {:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + assert_eq!(amount_y, 0); + println!("amount_x {}", amount_x); + assert_eq!(amount_x <= total_amount_x, true); + assert_diff_amount(total_amount_x, amount_x, 10); // less than 10bps +} + +#[test] +fn test_strategy_only_ask_side_favour_x() { + let active_id = 100; + let bin_step = 10; + let total_amount_x = 100_000_000; + let min_delta_id = 1; + let max_delta_id = 100; + let favor_x_in_active_id = true; + + let params = build_add_liquidity_params( + total_amount_x, + 0, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + assert!(amount_y > 0); + } + if bin_id == active_id { + assert!(amount_y == 0); + } + if bin_id > active_id { + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("liquidity distribution {:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + assert_eq!(amount_y, 0); + println!("amount_x {}", amount_x); + assert_eq!(amount_x <= total_amount_x, true); + assert_diff_amount(total_amount_x, amount_x, 10); // less than 10bps +} + +#[test] +fn test_strategy_both_sides_favor_y() { + let active_id = 100; + let bin_step = 10; + let total_amount_x = 100_000_000; + let total_amount_y = 200_000_000; + let min_delta_id = -50; + let max_delta_id = 100; + let favor_x_in_active_id = false; + + let params = build_add_liquidity_params( + total_amount_x, + total_amount_y, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + } + if bin_id == active_id { + assert!(amount_x == 0); + } + if bin_id > active_id { + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("{:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + println!("amount_x {} amount_y {}", amount_x, amount_y); + assert_eq!(amount_x <= total_amount_x, true); + assert_eq!(amount_y <= total_amount_y, true); + + assert_diff_amount(total_amount_x, amount_x, 10); // less than 10bps + assert_diff_amount(total_amount_y, amount_y, 10); // less than 10bps +} + +#[test] +fn test_strategy_both_sides_favor_x() { + let active_id = 100; + let bin_step = 10; + let total_amount_x = 100_000_000; + let total_amount_y = 200_000_000; + let min_delta_id = -50; + let max_delta_id = 100; + let favor_x_in_active_id = true; + + let params = build_add_liquidity_params( + total_amount_x, + total_amount_y, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + } + if bin_id == active_id { + assert!(amount_y == 0); + } + if bin_id > active_id { + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("{:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + println!("amount_x {} amount_y {}", amount_x, amount_y); + assert_eq!(amount_x <= total_amount_x, true); + assert_eq!(amount_y <= total_amount_y, true); + + assert_diff_amount(total_amount_x, amount_x, 10); // less than 10bps + assert_diff_amount(total_amount_y, amount_y, 10); // less than 10bps +} diff --git a/programs/zap/src/tests/dlmm_rebalancing_tests/mod.rs b/programs/zap/src/tests/dlmm_rebalancing_tests/mod.rs new file mode 100644 index 0000000..68ee30e --- /dev/null +++ b/programs/zap/src/tests/dlmm_rebalancing_tests/mod.rs @@ -0,0 +1,11 @@ +#[cfg(test)] +mod spot_strategy_tests; + +#[cfg(test)] +mod curve_strategy_tests; + +#[cfg(test)] +mod bid_ask_strategy_tests; + +#[cfg(test)] +mod utils; diff --git a/programs/zap/src/tests/dlmm_rebalancing_tests/spot_strategy_tests.rs b/programs/zap/src/tests/dlmm_rebalancing_tests/spot_strategy_tests.rs new file mode 100644 index 0000000..50d0a76 --- /dev/null +++ b/programs/zap/src/tests/dlmm_rebalancing_tests/spot_strategy_tests.rs @@ -0,0 +1,378 @@ +use crate::{ + tests::dlmm_rebalancing_tests::utils::{ + assert_diff_amount, build_add_liquidity_params, get_bin_add_liquidity, + get_liquidity_distribution, get_total_amount, AmountInBin, + }, + StrategyType, +}; + +const STRATEGY: StrategyType = StrategyType::Spot; + +#[test] +fn test_strategy_only_bid_side_favour_x() { + let active_id = 100; + let bin_step = 10; + let total_amount_y = 100_000; + let min_delta_id = -100; + let max_delta_id = -1; + let favor_x_in_active_id = true; + + let params = build_add_liquidity_params( + 0, + total_amount_y, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + // println!("amount_in_bins {:#?}", amount_in_bins); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + assert!(amount_y > 0); + } + if bin_id == active_id { + assert!(amount_y == 0); + } + if bin_id > active_id { + assert!(amount_x > 0); + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("{:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + assert_eq!(amount_x, 0); + println!("amount_y {}", amount_y); + assert_eq!(amount_y <= total_amount_y, true); + assert_diff_amount(total_amount_y, amount_y, 10); // less than 10bps +} + +#[test] +fn test_strategy_only_bid_side_favor_y() { + let active_id = 100; + let bin_step = 10; + let total_amount_y = 100_000; + let min_delta_id = -100; + let max_delta_id = 0; + let favor_x_in_active_id = false; + + let params = build_add_liquidity_params( + 0, + total_amount_y, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + // println!("amount_in_bins {:#?}", amount_in_bins); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + assert!(amount_y > 0); + } + if bin_id == active_id { + assert!(amount_x == 0); + assert!(amount_y > 0); + } + if bin_id > active_id { + assert!(amount_x > 0); + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("{:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + assert_eq!(amount_x, 0); + println!("amount_y {}", amount_y); + assert_eq!(amount_y <= total_amount_y, true); + assert_diff_amount(total_amount_y, amount_y, 10); // less than 10bps +} + +#[test] +fn test_strategy_only_ask_side_favour_y() { + let active_id = 100; + let bin_step = 10; + let total_amount_x = 100_000_000; + let min_delta_id = 1; + let max_delta_id = 100; + let favor_x_in_active_id = false; + + let params = build_add_liquidity_params( + total_amount_x, + 0, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + assert!(amount_y > 0); + } + if bin_id == active_id { + assert!(amount_x > 0); + assert!(amount_y == 0); + } + if bin_id > active_id { + assert!(amount_x > 0); + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("liquidity distribution {:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + assert_eq!(amount_y, 0); + println!("amount_x {}", amount_x); + assert_eq!(amount_x <= total_amount_x, true); + assert_diff_amount(total_amount_x, amount_x, 10); // less than 10bps +} + +#[test] +fn test_strategy_only_ask_side_favour_x() { + let active_id = 100; + let bin_step = 10; + let total_amount_x = 100_000_000; + let min_delta_id = 1; + let max_delta_id = 100; + let favor_x_in_active_id = true; + + let params = build_add_liquidity_params( + total_amount_x, + 0, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + assert!(amount_y > 0); + } + if bin_id == active_id { + assert!(amount_x > 0); + assert!(amount_y == 0); + } + if bin_id > active_id { + assert!(amount_x > 0); + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("liquidity distribution {:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + assert_eq!(amount_y, 0); + println!("amount_x {}", amount_x); + assert_eq!(amount_x <= total_amount_x, true); + assert_diff_amount(total_amount_x, amount_x, 10); // less than 10bps +} + +#[test] +fn test_strategy_both_sides_favor_y() { + let active_id = 100; + let bin_step = 10; + let total_amount_x = 100_000_000; + let total_amount_y = 200_000_000; + let min_delta_id = -50; + let max_delta_id = 100; + let favor_x_in_active_id = false; + + let params = build_add_liquidity_params( + total_amount_x, + total_amount_y, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + assert!(amount_y > 0); + } + if bin_id == active_id { + assert!(amount_x == 0); + assert!(amount_y > 0); + } + if bin_id > active_id { + assert!(amount_x > 0); + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("{:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + println!("amount_x {} amount_y {}", amount_x, amount_y); + assert_eq!(amount_x <= total_amount_x, true); + assert_eq!(amount_y <= total_amount_y, true); + + assert_diff_amount(total_amount_x, amount_x, 10); // less than 10bps + assert_diff_amount(total_amount_y, amount_y, 10); // less than 10bps +} + +#[test] +fn test_strategy_both_sides_favor_x() { + let active_id = 100; + let bin_step = 10; + let total_amount_x = 100_000_000; + let total_amount_y = 200_000_000; + let min_delta_id = -50; + let max_delta_id = 100; + let favor_x_in_active_id = true; + + let params = build_add_liquidity_params( + total_amount_x, + total_amount_y, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + STRATEGY, + ); + + let amount_in_bins = get_bin_add_liquidity(¶ms, active_id, bin_step).unwrap(); + let expected_min_bin_id = active_id.checked_add(min_delta_id).unwrap(); + let expected_max_bin_id = active_id.checked_add(max_delta_id).unwrap(); + + let generated_min_bin_id = amount_in_bins[0].bin_id; + let generated_max_bin_id = amount_in_bins[amount_in_bins.len() - 1].bin_id; + + assert_eq!(generated_min_bin_id, expected_min_bin_id); + assert_eq!(generated_max_bin_id, expected_max_bin_id); + + for &AmountInBin { + bin_id, + amount_x, + amount_y, + } in amount_in_bins.iter() + { + if bin_id < active_id { + assert_eq!(amount_x, 0); + assert!(amount_y > 0); + } + if bin_id == active_id { + assert!(amount_x > 0); + assert!(amount_y == 0); + } + if bin_id > active_id { + assert!(amount_x > 0); + assert!(amount_y == 0); + } + } + + let liquidity_distributions = get_liquidity_distribution(&amount_in_bins, bin_step); + println!("{:?}", liquidity_distributions); + + let (amount_x, amount_y) = get_total_amount(&amount_in_bins); + println!("amount_x {} amount_y {}", amount_x, amount_y); + assert_eq!(amount_x <= total_amount_x, true); + assert_eq!(amount_y <= total_amount_y, true); + + assert_diff_amount(total_amount_x, amount_x, 10); // less than 10bps + assert_diff_amount(total_amount_y, amount_y, 10); // less than 10bps +} diff --git a/programs/zap/src/tests/dlmm_rebalancing_tests/utils.rs b/programs/zap/src/tests/dlmm_rebalancing_tests/utils.rs new file mode 100644 index 0000000..13bafc9 --- /dev/null +++ b/programs/zap/src/tests/dlmm_rebalancing_tests/utils.rs @@ -0,0 +1,402 @@ +use anchor_lang::prelude::*; +use dlmm::types::{AddLiquidityParams as DlmmAddLiquidityParams, RebalanceLiquidityParams}; +use ruint::aliases::U256; +use std::ops::Neg; + +use crate::{ + error::ZapError, + price_math::{get_price_base_factor, get_price_from_id, pow}, + safe_math::SafeMath, + StrategyType, UnparsedAddLiquidityParams, ZapInRebalancingParams, +}; + +pub fn build_add_liquidity_params( + amount_x: u64, + amount_y: u64, + active_id: i32, + bin_step: u16, + min_delta_id: i32, + max_delta_id: i32, + favor_x_in_active_id: bool, + strategy: StrategyType, +) -> RebalanceLiquidityParams { + let params = ZapInRebalancingParams { + amount_x, + amount_y, + active_id, + bin_step, + min_delta_id, + max_delta_id, + favor_x_in_active_id, + strategy, + }; + + let UnparsedAddLiquidityParams { + x0, + y0, + delta_x, + delta_y, + bit_flag, + } = params.get_rebalancing_params().unwrap(); + + // bid side + let params = RebalanceLiquidityParams { + active_id, + max_active_bin_slippage: 0, + should_claim_fee: false, + should_claim_reward: false, + min_withdraw_x_amount: 0, + max_deposit_x_amount: 0, + min_withdraw_y_amount: 0, + max_deposit_y_amount: 0, + shrink_mode: 3, // we dont allow to shrink in both side + padding: [0; 31], + removes: vec![], + adds: vec![DlmmAddLiquidityParams { + min_delta_id, + max_delta_id, + x0, + y0, + delta_x, + delta_y, + favor_x_in_active_id, + bit_flag, + ..Default::default() + }], + }; + params +} +#[derive(Debug, Clone, Copy, Default)] +pub struct AmountInBin { + pub bin_id: i32, + pub amount_x: u64, + pub amount_y: u64, +} + +pub fn get_liquidity_distribution(amount_in_bins: &[AmountInBin], bin_step: u16) -> Vec { + let mut liquidity_distributions = vec![]; + for bin in amount_in_bins.iter() { + let price = U256::from(get_price_from_id(bin.bin_id, bin_step).unwrap()); + let (quote_amount_of_base_token, _) = U256::from(bin.amount_x) + .safe_mul(price) + .unwrap() + .overflowing_shr(64); + let quote_amount_of_base_token = u64::try_from(quote_amount_of_base_token) + .map_err(|_| ZapError::TypeCastFailed) + .unwrap(); + + let total_quote = quote_amount_of_base_token.safe_add(bin.amount_y).unwrap(); + + liquidity_distributions.push(total_quote); + } + return liquidity_distributions; +} + +pub fn get_total_amount(amount_in_bins: &[AmountInBin]) -> (u64, u64) { + let mut amount_x = 0; + let mut amount_y = 0; + for bin in amount_in_bins.iter() { + amount_x = amount_x.safe_add(bin.amount_x).unwrap(); + amount_y = amount_y.safe_add(bin.amount_y).unwrap(); + } + return (amount_x, amount_y); +} + +pub fn assert_diff_amount(a: u64, b: u64, max_bps: u64) { + let diff = if a > b { a - b } else { b - a }; + let diff_bps = diff.safe_mul(10_000).unwrap().safe_div(a).unwrap(); + assert!(diff_bps <= max_bps); +} + +pub fn get_bin_add_liquidity( + params: &RebalanceLiquidityParams, + active_id: i32, + bin_step: u16, +) -> Result> { + let mut amounts_in_bin = vec![]; + for bin_range in params.adds.iter() { + let add_liquidity_params = AddLiquidityParams { + min_delta_id: bin_range.min_delta_id, + max_delta_id: bin_range.max_delta_id, + x0: bin_range.x0, + y0: bin_range.y0, + delta_x: bin_range.delta_x, + delta_y: bin_range.delta_y, + bit_flag: bin_range.bit_flag, + favor_x_in_active_id: bin_range.favor_x_in_active_id, + padding: bin_range.padding, + }; + let mut amount_into_bin_range = + add_liquidity_params.to_amount_in_bins(active_id, bin_step)?; + amounts_in_bin.append(&mut amount_into_bin_range); + } + Ok(amounts_in_bin) +} + +// total_x = x0 * (1+b)^-(active_id) + (x0 + delta_x) * (1+b)^-(active_id + 1) + .. (x0 + delta_x * max_delta_id) * -(1+b)^(active_id + max_delta_id) +#[derive(AnchorSerialize, AnchorDeserialize, Eq, PartialEq, Clone, Debug, Default)] +pub struct AddLiquidityParams { + pub min_delta_id: i32, // min_bin_id = active_id + min_delta_id, min_delta_id <= max_delta_id + pub max_delta_id: i32, // max_bin_id = active_id + max_delta_id + pub x0: u64, + pub y0: u64, + pub delta_x: u64, + pub delta_y: u64, + pub bit_flag: u8, + pub favor_x_in_active_id: bool, // only x or only y in active id, that flag is used when user deposit both tokens in active id + pub padding: [u8; 16], // padding for future use +} + +pub const X0_NEG_FLAG: u8 = 0b1; +pub const Y0_NEG_FLAG: u8 = 0b10; +pub const DELTA_X_NEG_FLAG: u8 = 0b100; +pub const DELTA_Y_NEG_FLAG: u8 = 0b1000; + +impl AddLiquidityParams { + pub fn get_max_delta_id_both_side(&self) -> (i32, i32) { + let (bid_side_end_delta_id, ask_side_start_delta_id) = if self.favor_x_in_active_id { + (-1, 0) + } else { + (0, 1) + }; + (bid_side_end_delta_id, ask_side_start_delta_id) + } + + pub fn is_only_deposit_y(&self) -> bool { + let (bid_side_end_delta_id, _ask_side_start_delta_id) = self.get_max_delta_id_both_side(); + self.max_delta_id <= bid_side_end_delta_id + } + + pub fn is_only_deposit_x(&self) -> bool { + let (_bid_side_end_delta_id, ask_side_start_delta_id) = self.get_max_delta_id_both_side(); + self.min_delta_id >= ask_side_start_delta_id + } + + pub fn parse(&self) -> Result { + let &AddLiquidityParams { + x0, + y0, + delta_x, + delta_y, + bit_flag, + .. + } = self; + + let mut parsed_x0 = i128::from(x0); + let mut parsed_y0 = i128::from(y0); + let mut parsed_delta_x = i128::from(delta_x); + let mut parsed_delta_y = i128::from(delta_y); + + if bit_flag & X0_NEG_FLAG != 0 { + parsed_x0 = parsed_x0.neg(); + } + if bit_flag & Y0_NEG_FLAG != 0 { + parsed_y0 = parsed_y0.neg(); + } + if bit_flag & DELTA_X_NEG_FLAG != 0 { + parsed_delta_x = parsed_delta_x.neg(); + } + if bit_flag & DELTA_Y_NEG_FLAG != 0 { + parsed_delta_y = parsed_delta_y.neg(); + } + + Ok(ParsedAddLiquidityParams { + x0: parsed_x0, + y0: parsed_y0, + delta_x: parsed_delta_x, + delta_y: parsed_delta_y, + }) + } + + fn to_amount_in_bins(&self, active_id: i32, bin_step: u16) -> Result> { + let parsed_params = self.parse()?; + // only deposit y + if self.is_only_deposit_y() { + return get_amount_in_bins_bid_side( + active_id, + self.min_delta_id, + self.max_delta_id, + parsed_params.delta_y, + parsed_params.y0, + ); + } + // only deposit x + if self.is_only_deposit_x() { + return get_amount_in_bins_ask_side( + active_id, + bin_step, + self.min_delta_id, + self.max_delta_id, + parsed_params.delta_x, + parsed_params.x0, + ); + } + + // deposit both x and y, min_delta_id <= bid_side_end_delta_id && max_delta_id >= ask_side_start_delta_id + let (bid_side_end_delta_id, ask_side_start_delta_id) = self.get_max_delta_id_both_side(); + + let amounts_bid_side = get_amount_in_bins_bid_side( + active_id, + self.min_delta_id, + bid_side_end_delta_id, + parsed_params.delta_y, + parsed_params.y0, + )?; + + let amounts_ask_side = get_amount_in_bins_ask_side( + active_id, + bin_step, + ask_side_start_delta_id, + self.max_delta_id, + parsed_params.delta_x, + parsed_params.x0, + )?; + + Ok([amounts_bid_side, amounts_ask_side].concat()) + } +} + +#[derive(Default)] +pub struct ParsedAddLiquidityParams { + pub x0: i128, + pub y0: i128, + pub delta_x: i128, + pub delta_y: i128, +} + +// impl ParsedAddLiquidityParams { +// #[cfg(test)] +// pub fn unparse( +// &self, +// min_delta_id: i32, +// max_delta_id: i32, +// favor_x_in_active_id: bool, +// ) -> Result { +// let &ParsedAddLiquidityParams { +// x0, +// y0, +// delta_x, +// delta_y, +// } = self; + +// let mut bit_flag = 0; + +// if x0 < 0 { +// bit_flag |= X0_NEG_FLAG; +// } +// if y0 < 0 { +// bit_flag |= Y0_NEG_FLAG; +// } +// if delta_x < 0 { +// bit_flag |= DELTA_X_NEG_FLAG; +// } +// if delta_y < 0 { +// bit_flag |= DELTA_Y_NEG_FLAG; +// } + +// Ok(AddLiquidityParams { +// min_delta_id, +// max_delta_id, +// x0: u64::try_from(x0.abs()).map_err(|_| ZapError::TypeCastFailed)?, +// y0: u64::try_from(y0.abs()).map_err(|_| ZapError::TypeCastFailed)?, +// delta_x: u64::try_from(delta_x.abs()).map_err(|_| ZapError::TypeCastFailed)?, +// delta_y: u64::try_from(delta_y.abs()).map_err(|_| ZapError::TypeCastFailed)?, +// favor_x_in_active_id, +// bit_flag, +// padding: [0u8; 16], +// }) +// } +// } + +pub fn get_amount_in_bins_bid_side( + active_id: i32, + min_delta_id: i32, + max_delta_id: i32, + delta_y: i128, + y0: i128, +) -> Result> { + // This won't be negative because already validated min_bin_id <= max_bin_id at validate_and_get_bin_range + let bin_count = max_delta_id.safe_sub(min_delta_id)?.safe_add(1)?; + let mut amounts_in_bin = vec![AmountInBin::default(); bin_count as usize]; + + let min_bin_id = active_id.safe_add(min_delta_id)?; + let max_bin_id = active_id.safe_add(max_delta_id)?; + + for (idx, bin_id) in (min_bin_id..=max_bin_id).enumerate() { + let delta_bin = active_id.safe_sub(bin_id)?; + + let total_delta_y = delta_y.safe_mul(delta_bin.into())?; + + let amount_y = y0 + .safe_add(total_delta_y)? + .try_into() + .map_err(|_| ZapError::TypeCastFailed)?; + + amounts_in_bin[idx] = AmountInBin { + bin_id, + amount_x: 0, + amount_y, + }; + } + + Ok(amounts_in_bin) +} + +pub fn get_amount_in_bins_ask_side( + active_id: i32, + bin_step: u16, + min_delta_id: i32, + max_delta_id: i32, + delta_x: i128, + x0: i128, +) -> Result> { + // This won't be negative because already validated min_bin_id <= max_bin_id at validate_and_get_bin_range + let bin_count = max_delta_id.safe_sub(min_delta_id)?.safe_add(1)?; + + let base_u128 = get_price_base_factor(bin_step)?; + let base = U256::from(base_u128); + + let max_bin_id = active_id.safe_add(max_delta_id)?; + let min_bin_id = active_id.safe_add(min_delta_id)?; + + // we use inverse base price to avoid safe_div (safe_mul can save more CU) + let mut inverse_base_price = + U256::from(pow(base_u128, max_bin_id.neg().into()).ok_or_else(|| ZapError::MathOverflow)?); + + let mut amounts_in_bin = vec![AmountInBin::default(); bin_count as usize]; + let mut current_bin_id = max_bin_id; + + loop { + if current_bin_id < min_bin_id { + break; + } + + let delta_bin = current_bin_id.safe_sub(active_id)?; + + let total_delta_x = delta_x.safe_mul(delta_bin.into())?; + + let amount_x = + U256::try_from(x0.safe_add(total_delta_x)?).map_err(|_| ZapError::TypeCastFailed)?; + + let (amount_x, _) = amount_x.safe_mul(inverse_base_price)?.overflowing_shr(64); + + let amount_x = u64::try_from(amount_x).map_err(|_| ZapError::TypeCastFailed)?; + + let idx: usize = current_bin_id + .safe_sub(min_bin_id)? + .try_into() + .map_err(|_| ZapError::TypeCastFailed)?; + + amounts_in_bin[idx] = AmountInBin { + bin_id: current_bin_id, + amount_x, + amount_y: 0, + }; + + (inverse_base_price, _) = inverse_base_price.safe_mul(base)?.overflowing_shr(64); + + current_bin_id = current_bin_id.safe_sub(1)?; + } + + Ok(amounts_in_bin) +} diff --git a/programs/zap/src/tests/mod.rs b/programs/zap/src/tests/mod.rs index 8192fe4..ba4d612 100644 --- a/programs/zap/src/tests/mod.rs +++ b/programs/zap/src/tests/mod.rs @@ -1,2 +1,8 @@ #[cfg(test)] mod modify_payload_tests; + +#[cfg(test)] +mod dlmm_rebalancing_tests; + +#[cfg(test)] +mod zap_in_damm_v2_tests; diff --git a/programs/zap/src/tests/zap_in_damm_v2_tests.rs b/programs/zap/src/tests/zap_in_damm_v2_tests.rs new file mode 100644 index 0000000..55bb831 --- /dev/null +++ b/programs/zap/src/tests/zap_in_damm_v2_tests.rs @@ -0,0 +1,44 @@ +use std::fs; + +use anchor_spl::token_2022::spl_token_2022::extension::transfer_fee::TransferFee; +use damm_v2::{params::swap::TradeDirection, state::Pool}; + +use crate::{calculate_swap_amount, TransferFeeCalculator}; + +pub const SOL_USDC_CL_ADDRESS: &str = "8Pm2kZpnxD3hoMmt4bjStX2Pw2Z9abpbHzZxMPqxPmie"; + +fn get_pool_account(pool_address: &str) -> Pool { + let path = format!("../../fixtures/{}.bin", pool_address); + let account_data = fs::read(&path).expect("Failed to read account data"); + + let mut data_without_discriminator = account_data[8..].to_vec(); + let &pool: &Pool = bytemuck::from_bytes(&mut data_without_discriminator); + + pool +} + +#[test] +fn test_calculate_swap_result() { + let pool = get_pool_account(SOL_USDC_CL_ADDRESS); + + let trade_direction = TradeDirection::AtoB; + let remaining_amount = 1_000_000_000; //1 sol + let current_point = 1762837786; + let transfer_fee_calculator = TransferFeeCalculator { + epoch_transfer_fee: TransferFee::default(), + no_transfer_fee_extension: true, + }; + let (swap_amount, _swap_out_amount) = calculate_swap_amount( + &pool, + &transfer_fee_calculator, + &transfer_fee_calculator, + remaining_amount, + trade_direction, + current_point, + ) + .unwrap(); + + // test swap and add liquidity in meteora website + // https://app.meteora.ag/dammv2/8Pm2kZpnxD3hoMmt4bjStX2Pw2Z9abpbHzZxMPqxPmie?referrer=home + println!("swap_amount: {}", swap_amount); +} diff --git a/programs/zap/src/utils/damm_v2_utils.rs b/programs/zap/src/utils/damm_v2_utils.rs new file mode 100644 index 0000000..6db2e11 --- /dev/null +++ b/programs/zap/src/utils/damm_v2_utils.rs @@ -0,0 +1,478 @@ +use anchor_lang::prelude::*; +use damm_v2::{ + base_fee::{BaseFeeHandler, FeeRateLimiter}, + constants::fee::get_max_fee_numerator, + curve::{ + get_delta_amount_a_unsigned, get_delta_amount_b_unsigned, get_next_sqrt_price_from_input, + }, + params::swap::TradeDirection, + state::{ + fee::{BaseFeeMode, FeeMode, FeeOnAmountResult}, + Pool, + }, + u128x128_math::Rounding, + PoolError, +}; +use ruint::aliases::{U192, U256, U512}; + +use crate::{ + constants::MAX_BASIS_POINT, error::ZapError, safe_math::SafeMath, TransferFeeCalculator, +}; + +struct SwapAmountFromInput { + output_amount: u64, +} + +pub fn get_swap_result_status( + token_a_transfer_fee_calculator: &TransferFeeCalculator, + token_b_transfer_fee_calculator: &TransferFeeCalculator, + token_a_amount: u64, + token_b_amount: u64, + total_amount_a: u64, + total_amount_b: u64, +) -> Result { + let exclude_transfer_fee_token_a_amount = token_a_transfer_fee_calculator + .calculate_transfer_fee_excluded_amount(token_a_amount)? + .amount; + + let exclude_transfer_fee_token_b_amount = token_b_transfer_fee_calculator + .calculate_transfer_fee_excluded_amount(token_b_amount)? + .amount; + // if total_amount_a and total_amount_b is zero, it will return error, but outside function will skip that + let r1 = u128::from(exclude_transfer_fee_token_a_amount) + .safe_shl(64)? + .safe_div(u128::from(total_amount_a))?; + let r2 = u128::from(exclude_transfer_fee_token_b_amount) + .safe_shl(64)? + .safe_div(u128::from(total_amount_b))?; + + // compare a / Ta with b / Tb + // if a / Ta > b / Tb => Exceed A + // if a / Ta <= b / Tb => Exceed B + let diff = if r1 > r2 { + r1.safe_sub(r2)? + } else { + r2.safe_sub(r1)? + }; + + // if ratio (r1-r2) * 2 / (r1+r2) is less than 0.1%, we can stop + let prod = U192::from(diff) + .safe_mul(U192::from(2000))? + .safe_div(U192::from(r1).safe_add(U192::from(r2))?)?; + + if prod.is_zero() { + Ok(SwapResultStatus::Done) + } else { + if r1 > r2 { + Ok(SwapResultStatus::ExceededA) + } else { + Ok(SwapResultStatus::ExceededB) + } + } +} + +fn calculate_a_to_b_from_amount_in(pool: &Pool, amount_in: u64) -> Result { + // finding new target price + let next_sqrt_price = + get_next_sqrt_price_from_input(pool.sqrt_price, pool.liquidity, amount_in, true)?; + + if next_sqrt_price < pool.sqrt_min_price { + return Err(PoolError::PriceRangeViolation.into()); + } + + // finding output amount + let output_amount = get_delta_amount_b_unsigned( + next_sqrt_price, + pool.sqrt_price, + pool.liquidity, + Rounding::Down, + )?; + + Ok(SwapAmountFromInput { output_amount }) +} + +fn calculate_b_to_a_from_amount_in(pool: &Pool, amount_in: u64) -> Result { + // finding new target price + let next_sqrt_price = + get_next_sqrt_price_from_input(pool.sqrt_price, pool.liquidity, amount_in, false)?; + + if next_sqrt_price > pool.sqrt_max_price { + return Err(PoolError::PriceRangeViolation.into()); + } + // finding output amount + let output_amount = get_delta_amount_a_unsigned( + pool.sqrt_price, + next_sqrt_price, + pool.liquidity, + Rounding::Down, + )?; + + Ok(SwapAmountFromInput { output_amount }) +} + +struct SimulateSwapResult { + user_amount_in: u64, + user_amount_out: u64, + pool_amount_in: u64, + pool_amount_out: u64, +} + +/// Replicate exactly how swap_exact_in work +fn calculate_swap_result( + pool: &Pool, + token_a_transfer_fee_calculator: &TransferFeeCalculator, + token_b_transfer_fee_calculator: &TransferFeeCalculator, + current_point: u64, + amount_in: u64, + trade_direction: TradeDirection, + fee_handler: &FeeHandler, + fee_mode: &FeeMode, +) -> Result { + let excluded_fee_amount_in = if trade_direction == TradeDirection::AtoB { + token_a_transfer_fee_calculator + .calculate_transfer_fee_excluded_amount(amount_in)? + .amount + } else { + token_b_transfer_fee_calculator + .calculate_transfer_fee_excluded_amount(amount_in)? + .amount + }; + let trade_fee_numerator = fee_handler.get_trade_fee_numerator( + excluded_fee_amount_in, + current_point, + pool.activation_point, + trade_direction, + )?; + let actual_amount_in = if fee_mode.fees_on_input { + let FeeOnAmountResult { amount, .. } = pool.pool_fees.get_fee_on_amount( + excluded_fee_amount_in, + trade_fee_numerator, + fee_mode.has_referral, + false, + )?; + + amount + } else { + excluded_fee_amount_in + }; + let SwapAmountFromInput { output_amount, .. } = match trade_direction { + TradeDirection::AtoB => calculate_a_to_b_from_amount_in(pool, actual_amount_in), + TradeDirection::BtoA => calculate_b_to_a_from_amount_in(pool, actual_amount_in), + }?; + + let actual_amount_out = if fee_mode.fees_on_input { + output_amount + } else { + let FeeOnAmountResult { amount, .. } = pool.pool_fees.get_fee_on_amount( + output_amount, + trade_fee_numerator, + fee_mode.has_referral, + false, + )?; + amount + }; + + let excluded_fee_amount_out = if trade_direction == TradeDirection::AtoB { + token_b_transfer_fee_calculator + .calculate_transfer_fee_excluded_amount(actual_amount_out)? + .amount + } else { + token_a_transfer_fee_calculator + .calculate_transfer_fee_excluded_amount(actual_amount_out)? + .amount + }; + + Ok(SimulateSwapResult { + user_amount_in: excluded_fee_amount_out, + user_amount_out: amount_in, + pool_amount_in: actual_amount_in, + pool_amount_out: output_amount, + }) +} + +/// swap result status +#[repr(u8)] +#[derive(Clone, Copy, Debug, PartialEq, AnchorDeserialize, AnchorSerialize)] +pub enum SwapResultStatus { + Done, + ExceededA, + ExceededB, +} + +fn validate_swap_result( + swap_result: &SimulateSwapResult, + token_a_transfer_fee_calculator: &TransferFeeCalculator, + token_b_transfer_fee_calculator: &TransferFeeCalculator, + remaining_amount: u64, + total_amount_a: u64, + total_amount_b: u64, + trade_direction: TradeDirection, +) -> Result { + let &SimulateSwapResult { + user_amount_in, + user_amount_out, + pool_amount_in, + pool_amount_out, + } = swap_result; + // apply swap result + if trade_direction == TradeDirection::AtoB { + let user_amount_a = remaining_amount.safe_sub(user_amount_out)?; + let user_amount_b = user_amount_in; + let pool_amount_a = total_amount_a.safe_add(pool_amount_in)?; + let pool_amount_b = total_amount_b.safe_sub(pool_amount_out)?; + get_swap_result_status( + token_a_transfer_fee_calculator, + token_b_transfer_fee_calculator, + user_amount_a, + user_amount_b, + pool_amount_a, + pool_amount_b, + ) + } else { + let user_amount_a = user_amount_in; + let user_amount_b = remaining_amount.safe_sub(user_amount_out)?; + let pool_amount_a = total_amount_a.safe_sub(pool_amount_out)?; + let pool_amount_b = total_amount_b.safe_add(pool_amount_in)?; + get_swap_result_status( + token_a_transfer_fee_calculator, + token_b_transfer_fee_calculator, + user_amount_a, + user_amount_b, + pool_amount_a, + pool_amount_b, + ) + } +} + +struct FeeHandler { + pub rate_limiter_handler: FeeRateLimiter, // avoid copy + pub variable_fee_numerator: u128, + pub max_fee_numerator: u64, + pub total_fee_numerator: u64, + pub is_rate_limiter: bool, +} + +impl FeeHandler { + pub fn get_trade_fee_numerator( + &self, + input_amount: u64, + current_point: u64, + activation_point: u64, + trade_direction: TradeDirection, + ) -> Result { + if self.is_rate_limiter { + let base_fee_numerator = self + .rate_limiter_handler + .get_base_fee_numerator_from_included_fee_amount( + current_point, + activation_point, + trade_direction, + input_amount, + )?; + + get_total_fee_numerator( + base_fee_numerator, + self.variable_fee_numerator, + self.max_fee_numerator, + ) + } else { + Ok(self.total_fee_numerator) + } + } +} + +fn get_fee_handler( + pool: &Pool, + current_point: u64, + trade_direction: TradeDirection, +) -> Result { + let variable_fee_numerator = pool.pool_fees.dynamic_fee.get_variable_fee()?; + let max_fee_numerator = get_max_fee_numerator(pool.version)?; + + let base_fee_mode = pool.pool_fees.base_fee.base_fee_mode; + match BaseFeeMode::try_from(base_fee_mode) { + Ok(value) => { + match value { + BaseFeeMode::FeeSchedulerLinear | BaseFeeMode::FeeSchedulerExponential => { + let base_fee_handler = pool.pool_fees.base_fee.get_base_fee_handler()?; + // fee scheduler doesn't care for amount + let base_fee_numerator = base_fee_handler + .get_base_fee_numerator_from_included_fee_amount( + current_point, + pool.activation_point, + trade_direction, + 0, + )?; + + let total_fee_numerator = get_total_fee_numerator( + base_fee_numerator, + variable_fee_numerator, + max_fee_numerator, + )?; + Ok(FeeHandler { + rate_limiter_handler: FeeRateLimiter::default(), + variable_fee_numerator, + max_fee_numerator, + total_fee_numerator, + is_rate_limiter: false, + }) + } + BaseFeeMode::RateLimiter => { + let rate_limiter_handler = pool.pool_fees.base_fee.get_fee_rate_limiter()?; + Ok(FeeHandler { + rate_limiter_handler, + total_fee_numerator: 0, + variable_fee_numerator, + max_fee_numerator, + is_rate_limiter: true, + }) + } + } + } + _ => Err(ZapError::UnsupportedFeeMode.into()), + } +} + +fn get_total_fee_numerator( + base_fee_numerator: u64, + variable_fee_numerator: u128, + max_fee_numerator: u64, +) -> Result { + let total_fee_numerator = variable_fee_numerator.safe_add(base_fee_numerator.into())?; + let total_fee_numerator: u64 = total_fee_numerator + .try_into() + .map_err(|_| ZapError::TypeCastFailed)?; + + if total_fee_numerator > max_fee_numerator { + Ok(max_fee_numerator) + } else { + Ok(total_fee_numerator) + } +} +// we will use binary search +pub fn calculate_swap_amount( + pool: &Pool, + token_a_transfer_fee_calculator: &TransferFeeCalculator, + token_b_transfer_fee_calculator: &TransferFeeCalculator, + remaining_amount: u64, + trade_direction: TradeDirection, + current_point: u64, +) -> Result<(u64, u64)> { + let mut max_swap_amount = remaining_amount; + let mut min_swap_amount = 0; + let mut swap_in_amount = 0; + let mut swap_out_amount = 0; + + let fee_handler = get_fee_handler(pool, current_point, trade_direction)?; + + let fee_mode = FeeMode::get_fee_mode(pool.collect_fee_mode, trade_direction, false)?; + + let (pool_amount_a, pool_amount_b) = pool.get_reserves_amount()?; + + // max 20 loops + // For each loop program consumed ~ 5394.3 -> 5,395 CUs + // So the 20 loops will consume maximum ~ 107,900 CUs + for _i in 0..20 { + let delta_half = max_swap_amount.safe_sub(min_swap_amount)? >> 1; + let amount_in = min_swap_amount.safe_add(delta_half)?; + + if amount_in == swap_in_amount { + break; + } + + let swap_result = calculate_swap_result( + pool, + token_a_transfer_fee_calculator, + token_b_transfer_fee_calculator, + current_point, + amount_in, + trade_direction, + &fee_handler, + &fee_mode, + )?; + + // update swap amount + swap_in_amount = amount_in; + swap_out_amount = swap_result.user_amount_in; + + let status = validate_swap_result( + &swap_result, + token_a_transfer_fee_calculator, + token_b_transfer_fee_calculator, + remaining_amount, + pool_amount_a, + pool_amount_b, + trade_direction, + )?; + + match status { + SwapResultStatus::Done => { + #[cfg(test)] + println!("Done calculate swap result {}", _i); + break; + } + SwapResultStatus::ExceededA => { + if trade_direction == TradeDirection::AtoB { + // need to increase swap amount + min_swap_amount = swap_in_amount; + } else { + // need to decrease swap amount + max_swap_amount = swap_in_amount; + } + } + SwapResultStatus::ExceededB => { + if trade_direction == TradeDirection::AtoB { + // need to decrease swap amount + max_swap_amount = swap_in_amount; + } else { + // need to increase swap amount + min_swap_amount = swap_in_amount; + } + } + } + } + + Ok((swap_in_amount, swap_out_amount)) +} + +// Δa = L * (1 / √P_lower - 1 / √P_upper) => L = Δa / (1 / √P_lower - 1 / √P_upper) +pub fn get_liquidity_from_amount_a( + amount_a: u64, + sqrt_max_price: u128, + sqrt_price: u128, +) -> Result { + let price_delta = U512::from(sqrt_max_price.safe_sub(sqrt_price)?); + let prod = U512::from(amount_a) + .safe_mul(U512::from(sqrt_price))? + .safe_mul(U512::from(sqrt_max_price))?; + let liquidity = prod.safe_div(price_delta)?; // round down + Ok(liquidity.try_into().map_err(|_| ZapError::TypeCastFailed)?) +} + +// Δb = L (√P_upper - √P_lower) => L = Δb / (√P_upper - √P_lower) +pub fn get_liquidity_from_amount_b( + amount_b: u64, + sqrt_min_price: u128, + sqrt_price: u128, +) -> Result { + let price_delta = U256::from(sqrt_price.safe_sub(sqrt_min_price)?); + let quote_amount = U256::from(amount_b).safe_shl(128)?; + let liquidity = quote_amount.safe_div(price_delta)?; // round down + return Ok(liquidity.try_into().map_err(|_| ZapError::TypeCastFailed)?); +} + +// u32::MAX == 4_294_967_295, so we dont allow price change to go over 4_294_967_295 * 100 / 10_000 = 42_949_672 (%) +pub fn get_price_change_bps(pre_sqrt_price: u128, post_sqrt_price: u128) -> Result { + let price_diff = if pre_sqrt_price > post_sqrt_price { + pre_sqrt_price.safe_sub(post_sqrt_price)? + } else { + post_sqrt_price.safe_sub(pre_sqrt_price)? + }; + + let price_diff_prod = U192::from(price_diff).safe_mul(U192::from(MAX_BASIS_POINT))?; + + let price_diff_bps = price_diff_prod.div_ceil(U192::from(pre_sqrt_price)); + Ok(price_diff_bps + .try_into() + .map_err(|_| ZapError::TypeCastFailed)?) +} diff --git a/programs/zap/src/utils/dlmm_utils.rs b/programs/zap/src/utils/dlmm_utils.rs new file mode 100644 index 0000000..0ce8195 --- /dev/null +++ b/programs/zap/src/utils/dlmm_utils.rs @@ -0,0 +1,450 @@ +use anchor_lang::prelude::*; + +use std::ops::Neg; + +use damm_v2::safe_math::SafeMath; +use ruint::aliases::U256; + +use crate::{error::ZapError, price_math::get_price_from_id}; +#[derive(AnchorSerialize, AnchorDeserialize, Eq, PartialEq, Clone, Debug)] +pub enum StrategyType { + // spot + Spot, + // curve + Curve, + // bidAsk + BidAsk, +} + +pub struct ParsedAddLiquidityParams { + pub x0: i128, + pub y0: i128, + pub delta_x: i128, + pub delta_y: i128, +} + +pub struct UnparsedAddLiquidityParams { + pub x0: u64, + pub y0: u64, + pub delta_x: u64, + pub delta_y: u64, + pub bit_flag: u8, +} + +pub const X0_NEG_FLAG: u8 = 0b1; +pub const Y0_NEG_FLAG: u8 = 0b10; +pub const DELTA_X_NEG_FLAG: u8 = 0b100; +pub const DELTA_Y_NEG_FLAG: u8 = 0b1000; + +impl ParsedAddLiquidityParams { + pub fn unparse(&self) -> Result { + let &ParsedAddLiquidityParams { + x0, + y0, + delta_x, + delta_y, + } = self; + + let mut bit_flag = 0; + + if x0 < 0 { + bit_flag |= X0_NEG_FLAG; + } + if y0 < 0 { + bit_flag |= Y0_NEG_FLAG; + } + if delta_x < 0 { + bit_flag |= DELTA_X_NEG_FLAG; + } + if delta_y < 0 { + bit_flag |= DELTA_Y_NEG_FLAG; + } + + Ok(UnparsedAddLiquidityParams { + x0: u64::try_from(x0.abs()).map_err(|_| ZapError::TypeCastFailed)?, + y0: u64::try_from(y0.abs()).map_err(|_| ZapError::TypeCastFailed)?, + delta_x: u64::try_from(delta_x.abs()).map_err(|_| ZapError::TypeCastFailed)?, + delta_y: u64::try_from(delta_y.abs()).map_err(|_| ZapError::TypeCastFailed)?, + bit_flag, + }) + } +} + +pub struct ZapInRebalancingParams { + pub amount_x: u64, + pub amount_y: u64, + pub min_delta_id: i32, + pub max_delta_id: i32, + pub strategy: StrategyType, + pub favor_x_in_active_id: bool, + pub bin_step: u16, + pub active_id: i32, +} + +impl ZapInRebalancingParams { + pub fn get_rebalancing_params(&self) -> Result { + let strategy_handler: Box = match self.strategy { + StrategyType::Spot => Box::new(SpotHandler), + StrategyType::Curve => Box::new(CurveHandler), + StrategyType::BidAsk => Box::new(BidAskHandler), + }; + let parsed_params = self.get_parsed_rebalancing_params(&strategy_handler)?; + parsed_params.unparse() + } + + pub fn get_max_delta_id_both_side(&self) -> (i32, i32) { + let (bid_side_end_delta_id, ask_side_start_delta_id) = if self.favor_x_in_active_id { + (-1, 0) + } else { + (0, 1) + }; + (bid_side_end_delta_id, ask_side_start_delta_id) + } + + pub fn is_only_deposit_y(&self) -> bool { + let (bid_side_end_delta_id, _ask_side_start_delta_id) = self.get_max_delta_id_both_side(); + self.max_delta_id <= bid_side_end_delta_id + } + + pub fn is_only_deposit_x(&self) -> bool { + let (_bid_side_end_delta_id, ask_side_start_delta_id) = self.get_max_delta_id_both_side(); + self.min_delta_id >= ask_side_start_delta_id + } + + pub fn get_parsed_rebalancing_params( + &self, + strategy_handler: &Box, + ) -> Result { + // only deposit y + if self.is_only_deposit_y() { + let (y0, delta_y) = strategy_handler.find_y0_and_delta_y( + self.amount_y, + self.min_delta_id, + self.max_delta_id, + )?; + return Ok(ParsedAddLiquidityParams { + x0: 0, + y0, + delta_x: 0, + delta_y, + }); + } + // only deposit x + if self.is_only_deposit_x() { + let (x0, delta_x) = strategy_handler.find_x0_and_delta_x( + self.amount_x, + self.min_delta_id, + self.max_delta_id, + self.bin_step, + self.active_id, + )?; + return Ok(ParsedAddLiquidityParams { + x0, + y0: 0, + delta_x, + delta_y: 0, + }); + } + // deposit both x and y, + let (bid_side_end_delta_id, ask_side_start_delta_id) = self.get_max_delta_id_both_side(); + let (y0, delta_y) = strategy_handler.find_y0_and_delta_y( + self.amount_y, + self.min_delta_id, + bid_side_end_delta_id, + )?; + let (x0, delta_x) = strategy_handler.find_x0_and_delta_x( + self.amount_x, + ask_side_start_delta_id, + self.max_delta_id, + self.bin_step, + self.active_id, + )?; + Ok(ParsedAddLiquidityParams { + x0, + y0, + delta_x, + delta_y, + }) + } +} + +pub trait StrategyHandler { + fn find_y0_and_delta_y( + &self, + amount_y: u64, + min_delta_id: i32, + max_delta_id: i32, + ) -> Result<(i128, i128)>; + + fn find_x0_and_delta_x( + &self, + amount_x: u64, + min_delta_id: i32, + max_delta_id: i32, + bin_step: u16, + active_id: i32, + ) -> Result<(i128, i128)>; +} + +struct SpotHandler; +struct CurveHandler; +struct BidAskHandler; +impl StrategyHandler for SpotHandler { + fn find_y0_and_delta_y( + &self, + amount_y: u64, + min_delta_id: i32, + max_delta_id: i32, + ) -> Result<(i128, i128)> { + let total_bin = max_delta_id.safe_sub(min_delta_id)?.safe_add(1)?; + let y0 = + amount_y.safe_div(u64::try_from(total_bin).map_err(|_| ZapError::TypeCastFailed)?)?; + Ok((y0.into(), 0)) + } + // in spot delta_x == 0, so + // active_id + min_delta_id = x0 * (1+b)^-(active_id + min_delta_id) + // ... + // active_id + max_delta_id = x0 * (1+b)^-(active_id + max_delta_id) + fn find_x0_and_delta_x( + &self, + amount_x: u64, + min_delta_id: i32, + max_delta_id: i32, + bin_step: u16, + active_id: i32, + ) -> Result<(i128, i128)> { + if amount_x == 0 || max_delta_id <= 0 { + return Ok((0, 0)); + } + let mut total_weight = U256::ZERO; + let min_bin_id = active_id.safe_add(min_delta_id)?; + let max_bin_id = active_id.safe_add(max_delta_id)?; + + for bin_id in min_bin_id..=max_bin_id { + let base_price = U256::from(get_price_from_id(bin_id.neg(), bin_step)?); + total_weight = total_weight.safe_add(base_price)?; + } + let amount_x = U256::from(amount_x); + let x0 = amount_x.safe_shl(64)?.safe_div(total_weight)?; + let x0 = i128::try_from(x0).map_err(|_| ZapError::TypeCastFailed)?; + + Ok((x0, 0)) + } +} + +impl StrategyHandler for CurveHandler { + fn find_y0_and_delta_y( + &self, + amount_y: u64, + min_delta_id: i32, + max_delta_id: i32, + ) -> Result<(i128, i128)> { + // min_delta_id = -m1, max_delta_id = -m2 + // + // active_id - m2 = y0 + delta_y * m2 + // active_id - (m2 + 1) = y0 + delta_y * (m2-1) + // ... + // active_id - m1 = y0 + delta_y * m1 + // + // sum(amounts) = y0 * (m1-m2+1) + delta_y * (m1 * (m1+1)/2 - m2 * (m2-1)/2) + // set delta_y = -y0 / m1 + // sum(amounts) = y0 * (m1-m2+1) - y0 * (m1 * (m1+1)/2 - m2 * (m2-1)/2) / m1 + // A = (m1-m2+1) - (m1 * (m1+1)/2 - m2 * (m2-1)/2) / m1 + // y0 = sum(amounts) / A + // avoid precision loss: + // y0 = sum(amounts) * m1 / ((m1-m2+1) * m1 - (m1 * (m1+1)/2 - m2 * (m2-1)/2)) + // noted: y0 > 0 and delta_y < 0 in curve strategy + + // min_delta_id and min_delta_id <= 0 + if min_delta_id == max_delta_id { + // quick return + return Ok((amount_y.into(), 0)); + } + + let m1: i128 = min_delta_id.neg().into(); + let m2: i128 = max_delta_id.neg().into(); + + let a = (m1 - m2 + 1) * m1 - (m1 * (m1 + 1) / 2 - m2 * (m2 - 1) / 2); + let y0 = i128::from(amount_y) * m1 / a; + // we round down delta_y firstly + // m1 can't be zero because we've checked for min_delta_id <= max_delta_id, and both delta id is smaller than or equal 0 + let delta_y = -(y0 / m1); + + // then we update y0 to ensure the first amount (active_id - m1 = y0 + delta_y * m1) > 0 + // delta_y is negative and round up, while y0 is positive and round down + // it will ensure sum(amounts) <= amount_y + // sum(amounts) = y0 * (m1-m2+1) + delta_y * (m1 * (m1+1)/2 - m2 * (m2-1)/2) + // sum(amounts) = -(delta_y * m1) * (m1-m2+1) + delta_y * (m1 * (m1+1)/2 - m2 * (m2-1)/2) + let y0 = -(delta_y * m1); + + Ok((y0, delta_y)) + } + + fn find_x0_and_delta_x( + &self, + amount_x: u64, + min_delta_id: i32, + max_delta_id: i32, + bin_step: u16, + active_id: i32, + ) -> Result<(i128, i128)> { + // min_delta_id = m1, max_delta_id = m2 + // pm = (1+b)^-(active_id + m) + // + // active_id + m1 = (x0 + m1 * delta_x) * p(m1) + // active_id + m1 + 1 = (x0 + (m1 + 1) * delta_x) * p(m1+1) + // ... + // active_id + m2 = (x0 + m2 * delta_x) * p(m2) + // + // sum(amounts) = x0 * (p(m1)+..+p(m2)) + delta_x * (m1 * p(m1) + ... + m2 * p(m2)) + // set delta_x = -x0 / m2 + + // sum(amounts) = x0 * (p(m1)+..+p(m2)) - x0 * (m1 * p(m1) + ... + m2 * p(m2)) / m2 + // A = (p(m1)+..+p(m2)) - (m1 * p(m1) + ... + m2 * p(m2)) / m2 + // B = (p(m1)+..+p(m2)) + // C = (m1 * p(m1) + ... + m2 * p(m2)) / m2 + // x0 = sum(amounts) / (B-C) + // note: x0 >= 0 and delta_x <= 0 in curve strategy + + if min_delta_id == max_delta_id { + let bin_id = active_id.safe_add(min_delta_id)?; + return find_x0_and_delta_x_single_bin(bin_id, bin_step, amount_x); + } + + let mut b = U256::ZERO; + + let m1 = min_delta_id; + let m2 = max_delta_id; + + let mut c_numerator = U256::ZERO; + + for m in m1..=m2 { + let bin_id = active_id.safe_add(m)?; + let pm = U256::from(get_price_from_id(bin_id.neg(), bin_step)?); + + b = b.safe_add(pm)?; + + c_numerator = c_numerator.safe_add(U256::from(m).safe_mul(pm)?)?; + } + + let c = c_numerator.safe_div(U256::from(m2))?; + + let x0 = U256::from(amount_x) + .safe_shl(64)? + .safe_div(b.safe_sub(c)?)?; + let x0: i128 = x0.try_into().map_err(|_| ZapError::TypeCastFailed)?; + let m2: i128 = max_delta_id.into(); + // note: m2 impossible be zero because max_delta_id > min_delta_id >= 0 + let delta_x = -x0 / m2; + + // same handle as get y0, delta_y + let x0 = -(delta_x * m2); + + Ok((x0, delta_x)) + } +} + +impl StrategyHandler for BidAskHandler { + fn find_y0_and_delta_y( + &self, + amount_y: u64, + min_delta_id: i32, + max_delta_id: i32, + ) -> Result<(i128, i128)> { + // min_delta_id = -m1, max_delta_id = -m2 + // + // active_id - m2 = y0 + delta_y * m2 + // active_id - (m2 + 1) = y0 + delta_y * (m2-1) + // ... + // active_id - m1 = y0 + delta_y * m1 + // + // sum(amounts) = y0 * (m1-m2+1) + delta_y * (m1 * (m1+1)/2 - m2 * (m2-1)/2) + // set y0 = -delta_y * m2 + // sum(amounts) = -delta_y * m2 * (m1-m2+1) + delta_y * (m1 * (m1+1)/2 - m2 * (m2-1)/2) + // A = -m2 * (m1-m2+1) + (m1 * (m1+1)/2 - m2 * (m2-1)/2) + // delta_y = sum(amounts) / A + // note: in bid ask strategy: y0 < 0 and delta_y > 0 + + if min_delta_id == max_delta_id { + return Ok((amount_y.into(), 0)); + } + let m1: i128 = min_delta_id.neg().into(); + let m2: i128 = max_delta_id.neg().into(); + + let a = -m2 * (m1 - m2 + 1) + (m1 * (m1 + 1) / 2 - m2 * (m2 - 1) / 2); + let delta_y = i128::from(amount_y) / a; + let y0 = delta_y.neg() * m2; + Ok((y0, delta_y)) + } + + fn find_x0_and_delta_x( + &self, + amount_x: u64, + min_delta_id: i32, + max_delta_id: i32, + bin_step: u16, + active_id: i32, + ) -> Result<(i128, i128)> { + // min_delta_id = m1, max_delta_id = m2 + // pm = (1+b)^-(active_id + m) + // + // active_id + m1 = (x0 + m1 * delta_x) * p(m1) + // active_id + m1 + 1 = (x0 + (m1 + 1) * delta_x) * p(m1+1) + // ... + // active_id + m2 = (x0 + m2 * delta_x) * p(m2) + // + // sum(amounts) = x0 * (p(m1)+..+p(m2)) + delta_x * (m1 * p(m1) + ... + m2 * p(m2)) + // set x0 = -m1 * delta_x + + // sum(amounts) = -m1 * delta_x * (p(m1)+..+p(m2)) + delta_x * (m1 * p(m1) + ... + m2 * p(m2)) + // A = -m1 * (p(m1)+..+p(m2)) + (m1 * p(m1) + ... + m2 * p(m2)) + // B = m1 * (p(m1)+..+p(m2)) + // C = (m1 * p(m1) + ... + m2 * p(m2)) + // delta_x = sum(amounts) / (C-B) + // note: in bid ask strategy: x0 <= 0 and delta_x >= 0 + // except for the case min_delta_id == max_delta_id, x0 > 0 and delta_x = 0 (using the same result from curve strategy) + + if min_delta_id == max_delta_id { + let bin_id = active_id.safe_add(min_delta_id)?; + return find_x0_and_delta_x_single_bin(bin_id, bin_step, amount_x); + } + + let mut b = U256::ZERO; + let mut c = U256::ZERO; + let m1 = U256::try_from(min_delta_id).map_err(|_| ZapError::TypeCastFailed)?; + + for m in min_delta_id..=max_delta_id { + let bin_id = active_id.safe_add(m)?; + let pm = U256::from(get_price_from_id(bin_id.neg(), bin_step)?); + + let b_delta = m1.safe_mul(pm)?; + + b = b.safe_add(b_delta)?; + + let c_delta = U256::try_from(m) + .map_err(|_| ZapError::TypeCastFailed)? + .safe_mul(pm)?; + + c = c.safe_add(c_delta)?; + } + + //reverse b to c + let delta_x = U256::from(amount_x) + .safe_shl(64)? + .safe_div(c.safe_sub(b)?)?; + let delta_x: i128 = delta_x.try_into().map_err(|_| ZapError::TypeCastFailed)?; + let x0 = delta_x * i128::from(min_delta_id).neg(); + Ok((x0, delta_x)) + } +} + +fn find_x0_and_delta_x_single_bin( + bin_id: i32, + bin_step: u16, + amount_x: u64, +) -> Result<(i128, i128)> { + let pm = U256::from(get_price_from_id(bin_id, bin_step)?); + let x0 = U256::from(amount_x).safe_mul(pm)?.safe_shr(64)?; + let x0: i128 = x0.try_into().map_err(|_| ZapError::TypeCastFailed)?; + return Ok((x0, 0)); +} diff --git a/programs/zap/src/utils/mod.rs b/programs/zap/src/utils/mod.rs new file mode 100644 index 0000000..5641e17 --- /dev/null +++ b/programs/zap/src/utils/mod.rs @@ -0,0 +1,6 @@ +pub mod damm_v2_utils; +pub use damm_v2_utils::*; +pub mod dlmm_utils; +pub use dlmm_utils::*; +pub mod token; +pub use token::*; diff --git a/programs/zap/src/utils/token.rs b/programs/zap/src/utils/token.rs new file mode 100644 index 0000000..71ee38f --- /dev/null +++ b/programs/zap/src/utils/token.rs @@ -0,0 +1,76 @@ +use anchor_lang::prelude::*; +use anchor_spl::{ + token::Token, + token_2022::spl_token_2022::{ + self, + extension::{ + self, transfer_fee::TransferFee, BaseStateWithExtensions, StateWithExtensions, + }, + }, + token_interface::Mint, +}; +use damm_v2::token::TransferFeeExcludedAmount; + +use crate::error::ZapError; + +pub struct TransferFeeCalculator { + pub epoch_transfer_fee: TransferFee, + // cache this, so we could save compute unit for non transfer fee token mint + pub no_transfer_fee_extension: bool, +} + +impl TransferFeeCalculator { + pub fn calculate_transfer_fee_excluded_amount( + &self, + amount: u64, + ) -> Result { + if self.no_transfer_fee_extension { + Ok(TransferFeeExcludedAmount { + amount, + transfer_fee: 0, + }) + } else { + let transfer_fee = self + .epoch_transfer_fee + .calculate_fee(amount) + .ok_or_else(|| ZapError::MathOverflow)?; + let transfer_fee_excluded_amount = amount + .checked_sub(transfer_fee) + .ok_or_else(|| ZapError::MathOverflow)?; + return Ok(TransferFeeExcludedAmount { + amount: transfer_fee_excluded_amount, + transfer_fee, + }); + } + } +} + +pub fn new_transfer_fee_calculator<'info>( + token_mint: &InterfaceAccount<'info, Mint>, +) -> Result { + let token_mint_info = token_mint.to_account_info(); + if *token_mint_info.owner == Token::id() { + return Ok(TransferFeeCalculator { + epoch_transfer_fee: TransferFee::default(), + no_transfer_fee_extension: true, + }); + } + + let token_mint_data = token_mint_info.try_borrow_data()?; + let token_mint_unpacked = + StateWithExtensions::::unpack(&token_mint_data)?; + if let Ok(transfer_fee_config) = + token_mint_unpacked.get_extension::() + { + let epoch = Clock::get()?.epoch; + return Ok(TransferFeeCalculator { + epoch_transfer_fee: *transfer_fee_config.get_epoch_fee(epoch), + no_transfer_fee_extension: false, + }); + } else { + return Ok(TransferFeeCalculator { + epoch_transfer_fee: TransferFee::default(), + no_transfer_fee_extension: true, + }); + } +} diff --git a/tests/common/damm_v2.ts b/tests/common/damm_v2.ts index 136f66a..cb7336f 100644 --- a/tests/common/damm_v2.ts +++ b/tests/common/damm_v2.ts @@ -2,6 +2,7 @@ import { AnchorProvider, BN, IdlAccounts, + IdlTypes, Program, Wallet, } from "@coral-xyz/anchor"; @@ -13,12 +14,18 @@ import { Connection, Keypair, PublicKey, + SYSVAR_INSTRUCTIONS_PUBKEY, Transaction, } from "@solana/web3.js"; -import { LiteSVM, TransactionMetadata } from "litesvm"; +import { + FailedTransactionMetadata, + LiteSVM, + TransactionMetadata, +} from "litesvm"; import { AccountLayout, getAssociatedTokenAddressSync, + NATIVE_MINT, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, } from "@solana/spl-token"; @@ -41,10 +48,14 @@ import { getDammV2Pool, getDammV2Position, } from "./pda"; +import { + getLiquidityDeltaFromAmountA, + getLiquidityDeltaFromAmountB, +} from "@meteora-ag/cp-amm-sdk"; export const DAMM_V2_PROGRAM_ID = new PublicKey(CpAmmIDL.address); -export const DAMM_V2_SWAP_DISC = [248, 198, 158, 145, 225, 117, 135, 200] +export const DAMM_V2_SWAP_DISC = [248, 198, 158, 145, 225, 117, 135, 200]; export type Pool = IdlAccounts["pool"]; export type Position = IdlAccounts["position"]; @@ -154,7 +165,10 @@ export async function createDammV2Pool( svm: LiteSVM, creator: Keypair, tokenAMint: PublicKey, - tokenBMint: PublicKey + tokenBMint: PublicKey, + amountA?: BN, + amountB?: BN, + baseFeeParams?: any ): Promise { const program = createDammV2Program(); @@ -170,41 +184,59 @@ export async function createDammV2Pool( const tokenAVault = deriveDammV2TokenVaultAddress(tokenAMint, pool); const tokenBVault = deriveDammV2TokenVaultAddress(tokenBMint, pool); + const tokenAProgram = svm.getAccount(tokenAMint).owner; + const tokenBProgram = svm.getAccount(tokenBMint).owner; + const payerTokenA = getAssociatedTokenAddressSync( tokenAMint, creator.publicKey, true, - TOKEN_PROGRAM_ID + tokenAProgram ); const payerTokenB = getAssociatedTokenAddressSync( tokenBMint, creator.publicKey, true, - TOKEN_PROGRAM_ID + tokenBProgram ); + let liquidityDelta = LIQUIDITY_DELTA; + if (amountA && amountB) { + const liquidityFromA = getLiquidityDeltaFromAmountA( + amountA, + INIT_PRICE, + MAX_SQRT_PRICE + ); + + const liquidityFromB = getLiquidityDeltaFromAmountB( + amountB, + MIN_SQRT_PRICE, + INIT_PRICE + ); + + liquidityDelta = BN.min(liquidityFromA, liquidityFromB); + } + const transaction = await program.methods .initializeCustomizablePool({ poolFees: { - baseFee: { + baseFee: baseFeeParams ?? { cliffFeeNumerator: new BN(2_500_000), - numberOfPeriod: 0, - reductionFactor: new BN(0), - periodFrequency: new BN(0), - feeSchedulerMode: 0, + firstFactor: 0, + secondFactor: Array.from(new BN(0).toArrayLike(Buffer, "le", 8)), + thirdFactor: new BN(0), + baseFeeMode: 0, }, - protocolFeePercent: 20, - partnerFeePercent: 0, - referralFeePercent: 20, + padding: [], dynamicFee: null, }, sqrtMinPrice: MIN_SQRT_PRICE, sqrtMaxPrice: MAX_SQRT_PRICE, hasAlphaVault: false, - liquidity: LIQUIDITY_DELTA, + liquidity: liquidityDelta, sqrtPrice: INIT_PRICE, activationType: 0, - collectFeeMode: 0, + collectFeeMode: 1, activationPoint: null, }) .accountsPartial({ @@ -222,14 +254,17 @@ export async function createDammV2Pool( payerTokenA, payerTokenB, token2022Program: TOKEN_2022_PROGRAM_ID, - tokenAProgram: TOKEN_PROGRAM_ID, - tokenBProgram: TOKEN_PROGRAM_ID, + tokenAProgram: tokenAProgram, + tokenBProgram: tokenBProgram, }) .transaction(); transaction.recentBlockhash = svm.latestBlockhash(); transaction.sign(creator, positionNftKP); const result = svm.sendTransaction(transaction); + if (result instanceof FailedTransactionMetadata) { + console.log(result.meta().logs()); + } expect(result).instanceOf(TransactionMetadata); const tokenAVaultData = svm.getAccount(tokenAVault).data; @@ -244,6 +279,48 @@ export async function createDammV2Pool( return pool; } +export async function createDammV2Position( + svm: LiteSVM, + user: Keypair, + pool: PublicKey +): Promise<{ + position: PublicKey; + positionNftAccount: PublicKey; +}> { + const program = createDammV2Program(); + + const positionNftKP = Keypair.generate(); + const position = deriveDammV2PositionAddress(positionNftKP.publicKey); + const positionNftAccount = deriveDammV2PositionNftAccount( + positionNftKP.publicKey + ); + + const tx = await program.methods + .createPosition() + .accountsPartial({ + owner: user.publicKey, + positionNftMint: positionNftKP.publicKey, + poolAuthority: deriveDammV2PoolAuthority(), + positionNftAccount, + payer: user.publicKey, + pool, + position, + tokenProgram: TOKEN_2022_PROGRAM_ID, + }) + .transaction(); + + tx.recentBlockhash = svm.latestBlockhash(); + tx.sign(user, positionNftKP); + + const result = svm.sendTransaction(tx); + expect(result).instanceOf(TransactionMetadata); + + return { + position, + positionNftAccount, + }; +} + export async function createPositionAndAddLiquidity( svm: LiteSVM, user: Keypair, @@ -366,3 +443,79 @@ export async function removeLiquidity( }) .transaction(); } + +export async function swap(params: { + svm: LiteSVM; + user: PublicKey; + pool: PublicKey; + amountIn: BN; + inputTokenMint: PublicKey; + outputTokenMint: PublicKey; +}): Promise { + const dammV2Program = createDammV2Program(); + + const { svm, pool, amountIn, user, inputTokenMint, outputTokenMint } = params; + + const poolState = getDammV2Pool(svm, pool); + + const tokenAProgram = svm.getAccount(poolState.tokenAMint).owner; + + const tokenBProgram = svm.getAccount(poolState.tokenBMint).owner; + + const inputTokenAccount = getAssociatedTokenAddressSync( + inputTokenMint, + user, + true, + tokenAProgram + ); + + const outputTokenAccount = getAssociatedTokenAddressSync( + outputTokenMint, + user, + true, + tokenBProgram + ); + + const { tokenAMint, tokenBMint, tokenAVault, tokenBVault } = poolState; + + return await dammV2Program.methods + .swap({ + amountIn, + minimumAmountOut: new BN(0), + }) + .accountsPartial({ + poolAuthority: deriveDammV2PoolAuthority(), + pool, + payer: user, + inputTokenAccount, + outputTokenAccount, + tokenAVault, + tokenBVault, + tokenAProgram, + tokenBProgram, + tokenAMint, + tokenBMint, + referralTokenAccount: null, + }) + .remainingAccounts( + // TODO should check condition to add this in remaining accounts + [ + { + isSigner: false, + isWritable: false, + pubkey: SYSVAR_INSTRUCTIONS_PUBKEY, + }, + ] + ) + .transaction(); +} + +export function convertToRateLimiterSecondFactor( + maxLimiterDuration: BN, + maxFeeBps: BN +): number[] { + const buffer1 = maxLimiterDuration.toArrayLike(Buffer, "le", 4); + const buffer2 = maxFeeBps.toArrayLike(Buffer, "le", 4); + const buffer = Buffer.concat([buffer1, buffer2]); + return Array.from(buffer); +} diff --git a/tests/common/dlmm.ts b/tests/common/dlmm.ts index 2feb6d4..df8de24 100644 --- a/tests/common/dlmm.ts +++ b/tests/common/dlmm.ts @@ -6,7 +6,7 @@ import { Program, Wallet, } from "@coral-xyz/anchor"; - +import * as borsh from "borsh"; import { LbClmm } from "./idl/dlmm"; import DlmmIDL from "./idl/dlmm.json"; import { @@ -35,6 +35,7 @@ import { deriveBinArray, deriveBinArrayBitmapExtension, deriveDlmmEventAuthority, + deriveLbCustomizablePermissionless2, deriveLbPermissionless2, deriveOracle, derivePresetParameter2, @@ -43,6 +44,7 @@ import { } from "./pda"; import { getExtraAccountMetasForTransferHook } from "./transferHook/transferHookUtils"; import { getOrCreateAtA } from "./utils"; +import { pow } from "./math"; export type PresetParameter = Omit["presetParameter"], "">; export type BinLiquidityDistribution = @@ -53,6 +55,12 @@ export type BinArrayBitmapExtension = export type RemainingAccountsInfo = IdlTypes["remainingAccountsInfo"]; export type LbPairState = IdlAccounts["lbPair"]; + +export const StrategyType = { + Spot: { spot: {} }, + Curve: { curve: {} }, + BidAsk: { bidAsk: {} }, +}; export const AccountsType = { TransferHookX: { transferHookX: {}, @@ -65,7 +73,7 @@ export const AccountsType = { }, }; export const DLMM_PROGRAM_ID_LOCAL = new PublicKey( - "LbVRzDTvBDEcrthxfZ4RL6yiq3uZw8bS6MwtdY6UhFQ" + "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo" ); export const MEMO_PROGRAM_ID = new PublicKey( @@ -78,6 +86,10 @@ const CONSTANTS = Object.entries(DlmmIDL.constants); export const BIN_ARRAY_BITMAP_SIZE = new BN( CONSTANTS.find(([k, v]) => v.name == "BIN_ARRAY_BITMAP_SIZE")[1].value ); +export const DEFAULT_BIN_PER_POSITION = new BN( + CONSTANTS.find(([k, v]) => v.name == "DEFAULT_BIN_PER_POSITION")[1].value +); + export const DEFAULT_BITMAP_RANGE = [ BIN_ARRAY_BITMAP_SIZE.neg(), BIN_ARRAY_BITMAP_SIZE.sub(new BN(1)), @@ -87,10 +99,6 @@ export const MAX_BIN_PER_ARRAY = new BN( CONSTANTS.find(([k, v]) => v.name == "MAX_BIN_PER_ARRAY")[1].value ); -export const MAX_BIN_PER_POSITION = new BN( - CONSTANTS.find(([k, v]) => v.name == "MAX_BIN_PER_POSITION")[1].value -); - export const BASIS_POINT_MAX = new BN( CONSTANTS.find(([k, v]) => v.name == "BASIS_POINT_MAX")[1].value ); @@ -373,7 +381,7 @@ export async function createBinArrays( if (binArrayAccount == null) { const tx = await program.methods .initializeBinArray(idx) - .accounts({ + .accountsPartial({ binArray, funder: payer.publicKey, lbPair, @@ -402,7 +410,7 @@ export async function initializeTokenBadge( const program = createDlmmProgram(); const tx = await program.methods .initializeTokenBadge() - .accounts({ + .accountsPartial({ tokenMint, tokenBadge: deriveTokenBadge(tokenMint), admin: admin.publicKey, @@ -455,9 +463,15 @@ export async function createPresetParameter2( systemProgram: SystemProgram.programId, }) .transaction(); + svm.expireBlockhash(); tx.recentBlockhash = svm.latestBlockhash(); tx.sign(payer); + const result = svm.sendTransaction(tx); + if (result instanceof FailedTransactionMetadata) { + console.log(result.err()); + console.log(result.meta().logs()); + } expect(result).instanceOf(TransactionMetadata); } return presetParameter; @@ -529,6 +543,165 @@ export async function createDlmmPool( return lbPair; } +export async function initializeBinArrayBitmapExtension( + svm: LiteSVM, + lbPair: PublicKey, + payer: Keypair +) { + const [binArrayBitmapExtension] = deriveBinArrayBitmapExtension(lbPair); + const program = createDlmmProgram(); + const binArrayBitmapExtensionState = svm.getAccount(binArrayBitmapExtension); + if (!binArrayBitmapExtensionState) { + const tx = await program.methods + .initializeBinArrayBitmapExtension() + .accountsPartial({ + lbPair, + binArrayBitmapExtension, + systemProgram: SystemProgram.programId, + funder: payer.publicKey, + rent: SYSVAR_RENT_PUBKEY, + }) + .transaction(); + + tx.recentBlockhash = svm.latestBlockhash(); + tx.sign(payer); + + const result = svm.sendTransaction(tx); + expect(result).instanceOf(TransactionMetadata); + } +} + +export async function createDlmmPermissionlessPool(params: { + svm: LiteSVM; + creator: Keypair; + tokenX: PublicKey; + tokenY: PublicKey; + activeId: BN; + baseFactor: number; + binStep: number; +}) { + const { svm, creator, tokenX, tokenY, activeId, baseFactor, binStep } = + params; + const program = createDlmmProgram(); + const lbPair = deriveLbCustomizablePermissionless2(tokenX, tokenY); + + const [reserveX] = deriveReserve(tokenX, lbPair); + const [reserveY] = deriveReserve(tokenY, lbPair); + const [oracle] = deriveOracle(lbPair); + + const binArrayIndex = binIdToBinArrayIndex(activeId); + + const [minBinArrayIndex, maxBinArrayIndex] = DEFAULT_BITMAP_RANGE; + + const binArrayBitmapExtension = + binArrayIndex.gt(maxBinArrayIndex) || binArrayIndex.lt(minBinArrayIndex) + ? deriveBinArrayBitmapExtension(lbPair)[0] + : null; + + const tokenBadgeX = deriveTokenBadge(tokenX); + const tokenBadgeXState = svm.getAccount(tokenBadgeX); + const tokenBadgeY = deriveTokenBadge(tokenX); + const tokenBadgeYState = svm.getAccount(tokenBadgeY); + + const tokenProgramX = svm.getAccount(tokenX).owner; + const tokenProgramY = svm.getAccount(tokenY).owner; + const userTokenX = getAssociatedTokenAddressSync( + tokenX, + creator.publicKey, + true, + tokenProgramX + ); + + const userTokenY = getAssociatedTokenAddressSync( + tokenX, + creator.publicKey, + true, + tokenProgramX + ); + + const tx = await program.methods + .initializeCustomizablePermissionlessLbPair2({ + activeId: activeId.toNumber(), + binStep, + baseFactor, + activationPoint: null, + activationType: 0, + hasAlphaVault: false, + creatorPoolOnOffControl: true, + baseFeePowerFactor: 0, + padding: new Array(63).fill(0), + }) + .accountsPartial({ + funder: creator.publicKey, + lbPair, + reserveX, + reserveY, + oracle, + binArrayBitmapExtension, + tokenMintX: tokenX, + tokenMintY: tokenY, + tokenProgramX: svm.getAccount(tokenX).owner, + tokenProgramY: svm.getAccount(tokenY).owner, + tokenBadgeX: tokenBadgeXState ? tokenBadgeX : null, + tokenBadgeY: tokenBadgeYState ? tokenBadgeY : null, + systemProgram: SystemProgram.programId, + userTokenX, + userTokenY, + }) + .transaction(); + tx.recentBlockhash = svm.latestBlockhash(); + tx.sign(creator); + + const result = svm.sendTransaction(tx); + + if (result instanceof FailedTransactionMetadata) { + console.log(result.err()); + console.log(result.meta().logs()); + } + expect(result).instanceOf(TransactionMetadata); + + return lbPair; +} + +export async function createDlmmPosition( + svm: LiteSVM, + creator: Keypair, + lbPair: PublicKey, + lowerBinId: number, + width?: number +) { + const program = createDlmmProgram(); + const positionWidth = width ? width : DEFAULT_BIN_PER_POSITION.toNumber(); + const position = Keypair.generate(); + + let [binArrayBitmapExtension] = deriveBinArrayBitmapExtension(lbPair); + let binArrayBitmapExtensionState = svm.getAccount(binArrayBitmapExtension); + if (!binArrayBitmapExtensionState) { + binArrayBitmapExtension = null; + } + + const createPositionTx = await program.methods + .initializePosition(lowerBinId, positionWidth) + .accountsPartial({ + lbPair, + owner: creator.publicKey, + payer: creator.publicKey, + position: position.publicKey, + rent: SYSVAR_RENT_PUBKEY, + systemProgram: SystemProgram.programId, + }) + .transaction(); + + const finalTx = new Transaction().add(createPositionTx); + finalTx.recentBlockhash = svm.latestBlockhash(); + finalTx.sign(creator, position); + + const result = svm.sendTransaction(finalTx); + expect(result).instanceOf(TransactionMetadata); + + return position.publicKey; +} + export async function dlmmCreatePositionAndAddLiquidityRadius( svm: LiteSVM, creator: Keypair, @@ -546,7 +719,7 @@ export async function dlmmCreatePositionAndAddLiquidityRadius( width?: number ) { const program = createDlmmProgram(); - const positionWidth = width ? width : MAX_BIN_PER_POSITION.toNumber(); + const positionWidth = width ? width : DEFAULT_BIN_PER_POSITION.toNumber(); const position = Keypair.generate(); const userTokenX = getAssociatedTokenAddressSync( tokenXMint, @@ -1040,3 +1213,402 @@ export function getNextBinArrayIndexWithLiquidity( } return null; } + +export function getBinArrayBitmapExtensionState( + svm: LiteSVM, + program: Program, + binArrayBitmapExtension: PublicKey, + nullable = false +) { + const binArrayBitmapExtensionInfo = svm.getAccount(binArrayBitmapExtension); + if (!binArrayBitmapExtensionInfo || !binArrayBitmapExtensionInfo.data.length) + if (nullable) return null; + else throw new Error("Invalid binArrayBitmapExtension"); + + return program.coder.accounts.decode( + "binArrayBitmapExtension", + Buffer.from(binArrayBitmapExtensionInfo.data) + ); +} + +export async function dlmmSwap( + svm: LiteSVM, + user: PublicKey, + lbPair: PublicKey, + amount: BN, + swapForY: boolean, + remainingAccounts?: AccountMeta[] +) { + const program = createDlmmProgram(); + const lbPairState = getLbPairState(svm, lbPair); + + const tokenXProgram = svm.getAccount(lbPairState.tokenXMint).owner; + const tokenYProgram = svm.getAccount(lbPairState.tokenYMint).owner; + + let remainingAccountsData; + if (remainingAccounts) { + remainingAccountsData = remainingAccounts; + } else { + const binArrays = getBinArraysForSwap(svm, lbPair, swapForY); + + const binArraysAccountMeta: AccountMeta[] = binArrays.map((pubkey) => ({ + isSigner: false, + isWritable: true, + pubkey, + })); + remainingAccountsData = binArraysAccountMeta; + } + + const tokenXAta = getAssociatedTokenAddressSync( + lbPairState.tokenXMint, + user, + false, + tokenXProgram + ); + + const tokenYAta = getAssociatedTokenAddressSync( + lbPairState.tokenYMint, + user, + false, + tokenYProgram + ); + + const [inToken, outToken] = swapForY + ? [tokenXAta, tokenYAta] + : [tokenYAta, tokenXAta]; + + const [binArrayBitmapExtension] = deriveBinArrayBitmapExtension(lbPair); + + const bitmapExtensionState = getBinArrayBitmapExtensionState( + svm, + program, + binArrayBitmapExtension, + true + ); + + return await program.methods + .swap(amount, new BN(0)) + .accountsPartial({ + lbPair, + binArrayBitmapExtension: + bitmapExtensionState != null ? binArrayBitmapExtension : null, + reserveX: lbPairState.reserveX, + reserveY: lbPairState.reserveY, + tokenXMint: lbPairState.tokenXMint, + tokenYMint: lbPairState.tokenYMint, + tokenXProgram, + tokenYProgram, + user, + userTokenIn: inToken, + userTokenOut: outToken, + oracle: lbPairState.oracle, + hostFeeIn: null, + }) + .remainingAccounts(remainingAccountsData) + .transaction(); +} + +export function getBinArrayIndexesByBinArange( + lowerBinId: BN, + upperBinId: BN +): BN[] { + let indexes = []; + + let binArrayIndex = binIdToBinArrayIndex(lowerBinId); + while (true) { + indexes.push(binArrayIndex); + const [binArrayLowerBinId, binArrayUpperBinId] = + getBinArrayLowerUpperBinId(binArrayIndex); + + if ( + upperBinId.gte(binArrayLowerBinId) && + upperBinId.lte(binArrayUpperBinId) + ) { + break; + } else { + binArrayIndex = binArrayIndex.add(new BN(1)); + } + } + return indexes; +} + +export function getBinArrayState( + svm: LiteSVM, + binArray: PublicKey, + nullable = false +) { + const program = createDlmmProgram(); + const binArrayInfo = svm.getAccount(binArray); + if (!binArrayInfo || !binArrayInfo.data.length) + if (nullable) return null; + else throw new Error("Invalid binArray"); + + return program.coder.accounts.decode( + "binArray", + Buffer.from(binArrayInfo.data) + ); +} + +export function getPositionTotalLiquidityAllBin( + svm: LiteSVM, + position: PublicKey +): Number[][] { + const positionState = fetchAndDecodeDynamicPosition(svm, position); + + const lbPairState = getLbPairState(svm, positionState.globalData.lbPair); + let liquidities = []; + + let binArrayIndexes = getBinArrayIndexesByBinArange( + new BN(positionState.globalData.lowerBinId), + new BN(positionState.globalData.upperBinId) + ); + + const binArrays = binArrayIndexes.map((index) => { + let [key, _] = deriveBinArray(positionState.globalData.lbPair, index); + return getBinArrayState(svm, key); + }); + + for ( + let binPosition = positionState.globalData.lowerBinId; + binPosition <= positionState.globalData.upperBinId; + binPosition++ + ) { + const liquidity = getPositionLiquidityByBin( + positionState, + binArrays, + binPosition, + lbPairState.binStep + ); + + liquidities.push([binPosition, liquidity.toNumber()]); + } + + return liquidities; +} + +export type UserRewardInfo = IdlTypes["userRewardInfo"]; +export type FeeInfo = IdlTypes["feeInfo"]; +export type PositionBinData = { + liquidityShare: BN; + rewardInfo: UserRewardInfo; + feeInfo: FeeInfo; +}; +export type BinArray = IdlAccounts["binArray"]; + +export type DynamicPosition = { + globalData: { + lbPair: PublicKey; + owner: PublicKey; + lowerBinId: number; + upperBinId: number; + lastUpdatedAt: BN; + totalClaimedFeeXAmount: BN; + totalClaimedFeeYAmount: BN; + totalClaimedRewards: BN[]; + operator: PublicKey; + lockReleasePoint: BN; + padding0: number[]; + feeOwner: PublicKey; + binCount: BN; + length: BN; + reserved: number[]; + }; + positionBinData: PositionBinData[]; +}; + +export type Bin = IdlTypes["bin"]; + +export function getBinIndexInArray(binId: BN) { + const binArrayIndex = binIdToBinArrayIndex(binId); + const [lowerBinId, upperBinId] = getBinArrayLowerUpperBinId(binArrayIndex); + let index: BN; + if (!binId.isNeg()) { + index = binId.sub(lowerBinId); + } else { + index = MAX_BIN_PER_ARRAY.sub(upperBinId.sub(binId)).sub(new BN(1)); + } + return index; +} + +export function getPositionLiquidityByBin( + position: DynamicPosition, + binArrays: BinArray[], + binId: number, + binStep: number +) { + if ( + position.globalData.lowerBinId <= binId && + position.globalData.upperBinId >= binId + ) { + const binArrayIndex = binIdToBinArrayIndex(new BN(binId)); + for (const binArray of binArrays) { + if (binArrayIndex.eq(binArray.index)) { + const idx = binId - position.globalData.lowerBinId; + + const share = position.positionBinData[idx].liquidityShare; + + const bin = binArray.bins[ + getBinIndexInArray(new BN(binId)).toNumber() + ] as Bin; + + const supply = bin.liquiditySupply; + + if (supply.isZero()) { + return share; + } + + const x = share.mul(bin.amountX).div(supply); + const y = share.mul(bin.amountY).div(supply); + + const price = getPriceFromBinId(new BN(binId), new BN(binStep)); + const liquidity = getLiquidity(x, y, price); + + return liquidity; + } + } + } + + return null; +} + +export function getPriceFromBinId(id: BN, binStep: BN) { + const bps = binStep.shln(64).div(BASIS_POINT_MAX); + const base = new BN(1).shln(64).add(bps); + + return pow(base, id); +} + +export function getLiquidity(amountX: BN, amountY: BN, price: BN) { + const px = amountX.mul(price); + const y = amountY.shln(64); + + return px.add(y).shrn(64); +} + +export function getDlmmPositionState(svm: LiteSVM, position: PublicKey) { + const program = createDlmmProgram(); + const account = svm.getAccount(position); + + return program.coder.accounts.decode("positionV2", Buffer.from(account.data)); +} + +export function fetchAndDecodeDynamicPosition( + svm: LiteSVM, + position: PublicKey +): DynamicPosition { + const positionState = getDlmmPositionState(svm, position); + + const positionData = svm.getAccount(position); + + const remainingBytes = positionData.data.subarray(8 + 8112); + + const positionWidth = Math.max( + positionState.upperBinId - positionState.lowerBinId + 1, + DEFAULT_BIN_PER_POSITION.toNumber() + ); + + const binCount = positionState.upperBinId - positionState.lowerBinId + 1; + + const outerBinCount = + binCount > DEFAULT_BIN_PER_POSITION.toNumber() + ? binCount - DEFAULT_BIN_PER_POSITION.toNumber() + : 0; + + const positionBinDataSchema = { + array: { + type: { + struct: { + liquidityShare: "u128", + rewardInfo: { + struct: { + rewardPerTokenCompletes: { + array: { + type: "u128", + len: 2, + }, + }, + rewardPendings: { + array: { + type: "u64", + len: 2, + }, + }, + }, + }, + feeInfo: { + struct: { + feeXPerTokenComplete: "u128", + feeYPerTokenComplete: "u128", + feeXPending: "u64", + feeYPending: "u64", + }, + }, + }, + }, + len: outerBinCount, + }, + }; + + // @ts-ignore + // TODO: How to fix this? Somehow it decode it to bigint ... + let extendedPositionBinData: PositionBinData[] = + outerBinCount > 0 + ? borsh.deserialize(positionBinDataSchema, remainingBytes) + : []; + + // Map back to BN ... + extendedPositionBinData = extendedPositionBinData.map((b) => { + return { + liquidityShare: new BN(b.liquidityShare.toString()), + rewardInfo: { + rewardPendings: b.rewardInfo.rewardPendings.map( + (r) => new BN(r.toString()) + ), + rewardPerTokenCompletes: b.rewardInfo.rewardPerTokenCompletes.map( + (r) => new BN(r.toString()) + ), + }, + feeInfo: { + feeXPending: new BN(b.feeInfo.feeXPending.toString()), + feeYPending: new BN(b.feeInfo.feeYPending.toString()), + feeXPerTokenComplete: new BN(b.feeInfo.feeXPerTokenComplete.toString()), + feeYPerTokenComplete: new BN(b.feeInfo.feeYPerTokenComplete.toString()), + }, + }; + }); + + const innerPositionBinData: PositionBinData[] = []; + + for (let i = 0; i < DEFAULT_BIN_PER_POSITION.toNumber(); i++) { + innerPositionBinData.push({ + liquidityShare: positionState.liquidityShares[i], + rewardInfo: positionState.rewardInfos[i], + feeInfo: positionState.feeInfos[i], + }); + } + + const positionBinData = innerPositionBinData.concat(extendedPositionBinData); + + return { + globalData: { + lbPair: positionState.lbPair, + owner: positionState.owner, + lowerBinId: positionState.lowerBinId, + upperBinId: positionState.upperBinId, + lastUpdatedAt: positionState.lastUpdatedAt, + totalClaimedFeeXAmount: positionState.totalClaimedFeeXAmount, + totalClaimedFeeYAmount: positionState.totalClaimedFeeYAmount, + totalClaimedRewards: positionState.totalClaimedRewards, + operator: positionState.operator, + length: new BN(positionWidth), + binCount: new BN(binCount), + lockReleasePoint: positionState.lockReleasePoint, + feeOwner: positionState.feeOwner, + padding0: [], + reserved: [], + }, + positionBinData, + }; + + // +} diff --git a/tests/common/endpoints/index.ts b/tests/common/endpoints/index.ts new file mode 100644 index 0000000..91fcc7a --- /dev/null +++ b/tests/common/endpoints/index.ts @@ -0,0 +1,76 @@ +import { PublicKey, Transaction } from "@solana/web3.js"; +import { LiteSVM } from "litesvm"; +import { createZapProgram } from "./zapOut"; +import { deriveLedgerAccount } from "../pda"; +import BN from "bn.js"; + +export * from "./zapIn"; +export * from "./zapOut"; + +export async function initializeLedgerAccount( + owner: PublicKey +): Promise { + const program = createZapProgram(); + return await program.methods + .initializeLedgerAccount() + .accountsPartial({ + ledger: deriveLedgerAccount(owner), + owner, + payer: owner, + }) + .transaction(); +} + +export async function closeLedgerAccount( + owner: PublicKey +): Promise { + const program = createZapProgram(); + + return await program.methods + .closeLedgerAccount() + .accountsPartial({ + ledger: deriveLedgerAccount(owner), + owner, + rentReceiver: owner, + }) + .transaction(); +} + +export async function setLedgerBalance( + owner: PublicKey, + amount: BN, + isTokenA: boolean +): Promise { + const program = createZapProgram(); + + return await program.methods + .setLedgerBalance(amount, isTokenA) + .accountsPartial({ + ledger: deriveLedgerAccount(owner), + owner, + }) + .transaction(); +} + +export async function updateLedgerBalanceAfterSwap( + owner: PublicKey, + tokenAccount: PublicKey, + preSourceTokenAccount: BN, + maxTransferAmount: BN, + isTokenA: boolean +): Promise { + const program = createZapProgram(); + + return await program.methods + .updateLedgerBalanceAfterSwap( + preSourceTokenAccount, + maxTransferAmount, + isTokenA + ) + .accountsPartial({ + ledger: deriveLedgerAccount(owner), + tokenAccount, + owner, + }) + .transaction(); +} diff --git a/tests/common/endpoints/zapIn.ts b/tests/common/endpoints/zapIn.ts new file mode 100644 index 0000000..8f6c7f1 --- /dev/null +++ b/tests/common/endpoints/zapIn.ts @@ -0,0 +1,273 @@ +import { BN } from "@coral-xyz/anchor"; +import { LiteSVM } from "litesvm"; +import { + AccountMeta, + PublicKey, + SystemProgram, + Transaction, +} from "@solana/web3.js"; +import { DAMM_V2_PROGRAM_ID } from "../damm_v2"; +import { + deriveDammV2EventAuthority, + deriveDammV2PoolAuthority, + deriveDlmmEventAuthority, + deriveLedgerAccount, + getDammV2Pool, +} from "../pda"; +import { createZapProgram, ZAP_PROGRAM_ID } from "./zapOut"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; +import { + DLMM_PROGRAM_ID_LOCAL, + getBinArrayAccountMetaByBinRange, + getLbPairState, + MEMO_PROGRAM_ID, + SET_COMPUTE_UNIT_LIMIT_IX, + StrategyType, +} from "../dlmm"; + +export async function zapInDammv2(params: { + svm: LiteSVM; + user: PublicKey; + pool: PublicKey; + position: PublicKey; + positionNftAccount: PublicKey; + preSqrtPrice: BN; + maxSqrtPriceChangeBps: number; +}): Promise { + const zapProgram = createZapProgram(); + + const { + svm, + user, + pool, + position, + positionNftAccount, + preSqrtPrice, + maxSqrtPriceChangeBps, + } = params; + + const poolState = getDammV2Pool(svm, pool); + const { tokenAVault, tokenBVault, tokenAMint, tokenBMint } = poolState; + + const tokenAProgram = svm.getAccount(poolState.tokenAMint).owner; + + const tokenBProgram = svm.getAccount(poolState.tokenBMint).owner; + + const tokenAAccount = getAssociatedTokenAddressSync( + tokenAMint, + user, + true, + tokenAProgram + ); + + const tokenBAccount = getAssociatedTokenAddressSync( + tokenBMint, + user, + true, + tokenBProgram + ); + + return await zapProgram.methods + .zapInDammV2(preSqrtPrice, maxSqrtPriceChangeBps) + .accountsPartial({ + ledger: deriveLedgerAccount(user), + pool, + poolAuthority: deriveDammV2PoolAuthority(), + position, + tokenAAccount, + tokenBAccount, + tokenAVault, + tokenBVault, + tokenAMint, + tokenBMint, + positionNftAccount, + owner: user, + tokenAProgram, + tokenBProgram, + dammProgram: DAMM_V2_PROGRAM_ID, + dammEventAuthority: deriveDammV2EventAuthority(), + }) + .transaction(); +} + +export async function zapInDlmmforInitializedPosition(params: { + svm: LiteSVM; + owner: PublicKey; + lbPair: PublicKey; + position: PublicKey; + activeId: number; + minDeltaId: number; + maxDeltaId: number; + maxActiveBinSlippage: number; + favorXInActiveId: boolean; + strategy: any; + remainingAccountInfo: any; + binArrays: AccountMeta[]; + binArrayBitmapExtension: PublicKey; +}): Promise { + const program = createZapProgram(); + + const { + svm, + owner, + lbPair, + position, + activeId, + minDeltaId, + maxActiveBinSlippage, + maxDeltaId, + favorXInActiveId, + strategy, + remainingAccountInfo, + binArrayBitmapExtension, + binArrays, + } = params; + + const lbPairState = getLbPairState(svm, lbPair); + const { tokenXMint, tokenYMint, reserveX, reserveY } = lbPairState; + + const tokenXProgram = svm.getAccount(tokenXMint).owner; + const tokenYProgram = svm.getAccount(tokenYMint).owner; + + const userTokenX = getAssociatedTokenAddressSync( + tokenXMint, + owner, + true, + tokenXProgram + ); + + const userTokenY = getAssociatedTokenAddressSync( + tokenYMint, + owner, + true, + tokenYProgram + ); + + let binArrayBitmapExtensionState = svm.getAccount(binArrayBitmapExtension); + + return await program.methods + .zapInDlmmForInitializedPosition( + activeId, + minDeltaId, + maxDeltaId, + maxActiveBinSlippage, + favorXInActiveId, + strategy, + remainingAccountInfo + ) + .accountsPartial({ + ledger: deriveLedgerAccount(owner), + lbPair, + position, + binArrayBitmapExtension: binArrayBitmapExtensionState + ? binArrayBitmapExtension + : null, + userTokenX, + userTokenY, + reserveX, + reserveY, + tokenXMint, + tokenYMint, + tokenXProgram, + tokenYProgram, + dlmmProgram: DLMM_PROGRAM_ID_LOCAL, + owner, + rentPayer: owner, + memoProgram: MEMO_PROGRAM_ID, + dlmmEventAuthority: deriveDlmmEventAuthority(), + systemProgram: SystemProgram.programId, + }) + .remainingAccounts(binArrays) + .transaction(); +} + +export async function zapInDlmmforUnInitializedPosition(params: { + svm: LiteSVM; + owner: PublicKey; + lbPair: PublicKey; + position: PublicKey; + activeId: number; + minDeltaId: number; + maxDeltaId: number; + maxActiveBinSlippage: number; + favorXInActiveId: boolean; + strategy: any; + remainingAccountInfo: any; + binArrays: AccountMeta[]; + binArrayBitmapExtension: PublicKey; +}): Promise { + const program = createZapProgram(); + + const { + svm, + owner, + lbPair, + position, + activeId, + minDeltaId, + maxDeltaId, + maxActiveBinSlippage, + favorXInActiveId, + strategy, + remainingAccountInfo, + binArrayBitmapExtension, + binArrays, + } = params; + + const lbPairState = getLbPairState(svm, lbPair); + const { tokenXMint, tokenYMint, reserveX, reserveY } = lbPairState; + + const tokenXProgram = svm.getAccount(tokenXMint).owner; + const tokenYProgram = svm.getAccount(tokenYMint).owner; + + const userTokenX = getAssociatedTokenAddressSync( + tokenXMint, + owner, + true, + tokenXProgram + ); + + const userTokenY = getAssociatedTokenAddressSync( + tokenYMint, + owner, + true, + tokenYProgram + ); + + let binArrayBitmapExtensionState = svm.getAccount(binArrayBitmapExtension); + + return await program.methods + .zapInDlmmForUninitializedPosition( + minDeltaId, + maxDeltaId, + activeId, + maxActiveBinSlippage, + favorXInActiveId, + strategy, + remainingAccountInfo + ) + .accountsPartial({ + ledger: deriveLedgerAccount(owner), + lbPair, + position, + binArrayBitmapExtension: binArrayBitmapExtensionState + ? binArrayBitmapExtension + : null, + userTokenX, + userTokenY, + reserveX, + reserveY, + tokenXMint, + tokenYMint, + tokenXProgram, + tokenYProgram, + dlmmProgram: DLMM_PROGRAM_ID_LOCAL, + owner, + rentPayer: owner, + memoProgram: MEMO_PROGRAM_ID, + dlmmEventAuthority: deriveDlmmEventAuthority(), + systemProgram: SystemProgram.programId, + }) + .remainingAccounts(binArrays) + .transaction(); +} diff --git a/tests/common/zap.ts b/tests/common/endpoints/zapOut.ts similarity index 87% rename from tests/common/zap.ts rename to tests/common/endpoints/zapOut.ts index 1dbfb49..bc351cc 100644 --- a/tests/common/zap.ts +++ b/tests/common/endpoints/zapOut.ts @@ -1,46 +1,42 @@ import { AnchorProvider, BN, Program, Wallet } from "@coral-xyz/anchor"; -import { - FailedTransactionMetadata, - LiteSVM, - TransactionMetadata, -} from "litesvm"; +import { LiteSVM } from "litesvm"; -import ZapIDL from "../../target/idl/zap.json"; -import { Zap } from "../../target/types/zap"; -import { - createAssociatedTokenAccountInstruction, - getAssociatedTokenAddressSync, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; +import ZapIDL from "../../../target/idl/zap.json"; +import { Zap } from "../../../target/types/zap"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { clusterApiUrl, Connection, Keypair, PublicKey, Transaction, - TransactionInstruction, } from "@solana/web3.js"; import { DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISC, getDammV2RemainingAccounts, -} from "./damm_v2"; +} from "../damm_v2"; import { DLMM_PROGRAM_ID_LOCAL, DLMM_SWAP_DISC, getDlmmRemainingAccounts, getLbPairState, MEMO_PROGRAM_ID, -} from "./dlmm"; +} from "../dlmm"; import { expect } from "chai"; import { getJupRemainingAccounts, JUP_ROUTE_DISC, JUP_V6_PROGRAM_ID, RoutePlanStep, -} from "./jup"; -import { getOrCreateAtA, getTokenBalance, getTokenProgram } from "./utils"; -import { getDammV2Pool } from "./pda"; +} from "../jup"; +import { + convertAccountTypeToNumber, + getOrCreateAtA, + getTokenBalance, + getTokenProgram, +} from "../utils"; +import { getDammV2Pool } from "../pda"; export const ZAP_PROGRAM_ID = new PublicKey(ZapIDL.address); @@ -106,7 +102,7 @@ export async function zapOutDammv2( percentage: 100, offsetAmountIn: 8, preUserTokenBalance, - maxSwapAmount: new BN("100000000000"), + maxSwapAmount: new BN("100000000000"), payloadData, }) .accountsPartial({ @@ -189,7 +185,7 @@ export async function zapOutDlmm( percentage: 100, offsetAmountIn: 8, // disc then amount_in preUserTokenBalance, - maxSwapAmount: new BN("100000000000"), + maxSwapAmount: new BN("100000000000"), payloadData, }) .accountsPartial({ @@ -278,18 +274,3 @@ export async function zapOutJupV6( .remainingAccounts(remainingAccounts) .transaction(); } - -function convertAccountTypeToNumber(accountType: object): number { - if (JSON.stringify(accountType) === JSON.stringify({ transferHookX: {} })) { - return 0; - } - - if (JSON.stringify(accountType) === JSON.stringify({ transferHookY: {} })) { - return 1; - } - if ( - JSON.stringify(accountType) === JSON.stringify({ transferHookReward: {} }) - ) { - return 2; - } -} diff --git a/tests/common/idl/damm_v2.ts b/tests/common/idl/damm_v2.ts index 59193df..3a1691c 100644 --- a/tests/common/idl/damm_v2.ts +++ b/tests/common/idl/damm_v2.ts @@ -8,7 +8,7 @@ export type CpAmm = { address: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"; metadata: { name: "cpAmm"; - version: "0.1.2"; + version: "0.1.5"; spec: "0.1.0"; description: "Created with Anchor"; }; @@ -125,29 +125,7 @@ export type CpAmm = { accounts: [ { name: "poolAuthority"; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ]; - } - ]; - }; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; }, { name: "pool"; @@ -248,29 +226,7 @@ export type CpAmm = { accounts: [ { name: "poolAuthority"; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ]; - } - ]; - }; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; }, { name: "pool"; @@ -370,29 +326,7 @@ export type CpAmm = { accounts: [ { name: "poolAuthority"; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ]; - } - ]; - }; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; }, { name: "pool"; @@ -670,29 +604,7 @@ export type CpAmm = { accounts: [ { name: "poolAuthority"; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ]; - } - ]; - }; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; }, { name: "pool"; @@ -899,29 +811,7 @@ export type CpAmm = { }, { name: "poolAuthority"; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ]; - } - ]; - }; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; }, { name: "rentReceiver"; @@ -1321,29 +1211,7 @@ export type CpAmm = { }, { name: "poolAuthority"; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ]; - } - ]; - }; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; }, { name: "payer"; @@ -1597,29 +1465,7 @@ export type CpAmm = { }, { name: "poolAuthority"; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ]; - } - ]; - }; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; }, { name: "pool"; @@ -1829,29 +1675,7 @@ export type CpAmm = { }, { name: "poolAuthority"; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ]; - } - ]; - }; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; }, { name: "pool"; @@ -2065,29 +1889,7 @@ export type CpAmm = { }, { name: "poolAuthority"; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ]; - } - ]; - }; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; }, { name: "pool"; @@ -2239,29 +2041,7 @@ export type CpAmm = { accounts: [ { name: "poolAuthority"; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ]; - } - ]; - }; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; }, { name: "pool"; @@ -2536,29 +2316,7 @@ export type CpAmm = { accounts: [ { name: "poolAuthority"; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ]; - } - ]; - }; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; }, { name: "pool"; @@ -2668,29 +2426,7 @@ export type CpAmm = { accounts: [ { name: "poolAuthority"; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 112, - 111, - 111, - 108, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ]; - } - ]; - }; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; }, { name: "pool"; @@ -2847,20 +2583,137 @@ export type CpAmm = { ]; }, { - name: "swap"; - discriminator: [248, 198, 158, 145, 225, 117, 135, 200]; + name: "splitPosition"; + discriminator: [172, 241, 221, 138, 161, 29, 253, 42]; accounts: [ { - name: "poolAuthority"; + 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: [ - 112, - 111, + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, 111, - 108, + 114, + 105, + 116, + 121 + ]; + } + ]; + }; + }, + { + name: "program"; + } + ]; + args: [ + { + name: "params"; + type: { + defined: { + name: "splitPositionParameters"; + }; + }; + } + ]; + }, + { + name: "splitPosition2"; + discriminator: [221, 147, 228, 207, 140, 212, 17, 119]; + 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, @@ -2876,6 +2729,25 @@ export type CpAmm = { ]; }; }, + { + name: "program"; + } + ]; + args: [ + { + name: "numerator"; + type: "u32"; + } + ]; + }, + { + name: "swap"; + discriminator: [248, 198, 158, 145, 225, 117, 135, 200]; + accounts: [ + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, { name: "pool"; docs: ["Pool account"]; @@ -2975,17 +2847,67 @@ export type CpAmm = { ]; }, { - name: "updateRewardDuration"; - discriminator: [138, 174, 196, 169, 213, 235, 254, 107]; + name: "swap2"; + discriminator: [65, 75, 63, 76, 235, 91, 91, 136]; accounts: [ + { + name: "poolAuthority"; + address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"; + }, { name: "pool"; + docs: ["Pool account"]; writable: true; }, { - name: "signer"; + 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: { @@ -3021,18 +2943,18 @@ export type CpAmm = { ]; args: [ { - name: "rewardIndex"; - type: "u8"; - }, - { - name: "newDuration"; - type: "u64"; + name: "params"; + type: { + defined: { + name: "swapParameters2"; + }; + }; } ]; }, { - name: "updateRewardFunder"; - discriminator: [211, 28, 48, 32, 215, 160, 35, 23]; + name: "updateRewardDuration"; + discriminator: [138, 174, 196, 169, 213, 235, 254, 107]; accounts: [ { name: "pool"; @@ -3081,26 +3003,37 @@ export type CpAmm = { type: "u8"; }, { - name: "newFunder"; - type: "pubkey"; + name: "newDuration"; + type: "u64"; } ]; }, { - name: "withdrawIneligibleReward"; - discriminator: [148, 206, 42, 195, 247, 49, 103, 8]; + name: "updateRewardFunder"; + discriminator: [211, 28, 48, 32, 215, 160, 35, 23]; accounts: [ { - name: "poolAuthority"; + name: "pool"; + writable: true; + }, + { + name: "signer"; + signer: true; + }, + { + name: "eventAuthority"; pda: { seeds: [ { kind: "const"; value: [ - 112, - 111, - 111, - 108, + 95, + 95, + 101, + 118, + 101, + 110, + 116, 95, 97, 117, @@ -3116,6 +3049,29 @@ export type CpAmm = { ]; }; }, + { + 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; @@ -3270,6 +3226,10 @@ export type CpAmm = { name: "evtInitializeReward"; discriminator: [129, 91, 188, 3, 246, 52, 185, 249]; }, + { + name: "evtLiquidityChange"; + discriminator: [197, 171, 78, 127, 224, 211, 87, 13]; + }, { name: "evtLockPosition"; discriminator: [168, 63, 108, 83, 219, 82, 2, 200]; @@ -3286,10 +3246,18 @@ export type CpAmm = { name: "evtSetPoolStatus"; discriminator: [100, 213, 74, 3, 95, 91, 228, 146]; }, + { + name: "evtSplitPosition2"; + discriminator: [165, 32, 203, 174, 72, 100, 233, 103]; + }, { name: "evtSwap"; discriminator: [27, 60, 21, 213, 138, 170, 187, 147]; }, + { + name: "evtSwap2"; + discriminator: [189, 66, 51, 168, 38, 80, 117, 153]; + }, { name: "evtUpdateRewardDuration"; discriminator: [149, 135, 65, 231, 129, 153, 65, 57]; @@ -3523,6 +3491,51 @@ export type CpAmm = { 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"; + }, + { + code: 6047; + name: "invalidBaseFeeMode"; + msg: "Invalid base fee mode"; + }, + { + code: 6048; + name: "invalidFeeRateLimiter"; + msg: "Invalid fee rate limiter"; + }, + { + code: 6049; + name: "failToValidateSingleSwapInstruction"; + msg: "Fail to validate single swap instruction in rate limiter"; + }, + { + code: 6050; + name: "invalidFeeScheduler"; + msg: "Invalid fee scheduler"; + }, + { + code: 6051; + name: "undeterminedError"; + msg: "Undetermined error"; + }, + { + code: 6052; + name: "invalidPoolVersion"; + msg: "Invalid pool version"; } ]; types: [ @@ -3563,7 +3576,7 @@ export type CpAmm = { type: "u64"; }, { - name: "feeSchedulerMode"; + name: "baseFeeMode"; type: "u8"; }, { @@ -3573,15 +3586,17 @@ export type CpAmm = { }; }, { - name: "numberOfPeriod"; + name: "firstFactor"; type: "u16"; }, { - name: "periodFrequency"; - type: "u64"; + name: "secondFactor"; + type: { + array: ["u8", 8]; + }; }, { - name: "reductionFactor"; + name: "thirdFactor"; type: "u64"; } ]; @@ -3597,19 +3612,21 @@ export type CpAmm = { type: "u64"; }, { - name: "numberOfPeriod"; + name: "firstFactor"; type: "u16"; }, { - name: "periodFrequency"; - type: "u64"; + name: "secondFactor"; + type: { + array: ["u8", 8]; + }; }, { - name: "reductionFactor"; + name: "thirdFactor"; type: "u64"; }, { - name: "feeSchedulerMode"; + name: "baseFeeMode"; type: "u8"; } ]; @@ -3629,7 +3646,7 @@ export type CpAmm = { type: "u64"; }, { - name: "feeSchedulerMode"; + name: "baseFeeMode"; type: "u8"; }, { @@ -3639,15 +3656,17 @@ export type CpAmm = { }; }, { - name: "numberOfPeriod"; + name: "firstFactor"; type: "u16"; }, { - name: "periodFrequency"; - type: "u64"; + name: "secondFactor"; + type: { + array: ["u8", 8]; + }; }, { - name: "reductionFactor"; + name: "thirdFactor"; type: "u64"; }, { @@ -4281,6 +4300,18 @@ export type CpAmm = { { name: "transferFeeExcludedAmountIn"; type: "u64"; + }, + { + name: "rewardDurationEnd"; + type: "u64"; + }, + { + name: "preRewardRate"; + type: "u128"; + }, + { + name: "postRewardRate"; + type: "u128"; } ]; }; @@ -4398,6 +4429,10 @@ export type CpAmm = { name: "funder"; type: "pubkey"; }, + { + name: "creator"; + type: "pubkey"; + }, { name: "rewardIndex"; type: "u8"; @@ -4409,6 +4444,66 @@ export type CpAmm = { ]; }; }, + { + name: "evtLiquidityChange"; + type: { + kind: "struct"; + fields: [ + { + name: "pool"; + type: "pubkey"; + }, + { + name: "position"; + type: "pubkey"; + }, + { + name: "owner"; + type: "pubkey"; + }, + { + name: "tokenAAmount"; + type: "u64"; + }, + { + name: "tokenBAmount"; + type: "u64"; + }, + { + name: "transferFeeIncludedTokenAAmount"; + type: "u64"; + }, + { + name: "transferFeeIncludedTokenBAmount"; + type: "u64"; + }, + { + name: "reserveAAmount"; + type: "u64"; + }, + { + name: "reserveBAmount"; + type: "u64"; + }, + { + name: "liquidityDelta"; + type: "u128"; + }, + { + name: "tokenAAmountThreshold"; + type: "u64"; + }, + { + name: "tokenBAmountThreshold"; + type: "u64"; + }, + { + name: "changeType"; + type: "u8"; + } + ]; + }; + }, { name: "evtLockPosition"; type: { @@ -4478,7 +4573,123 @@ export type CpAmm = { }; }, { - name: "evtRemoveLiquidity"; + 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: "evtSplitPosition2"; + 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: "splitPositionParameters2"; + }; + }; + } + ]; + }; + }, + { + name: "evtSwap"; type: { kind: "struct"; fields: [ @@ -4487,34 +4698,42 @@ export type CpAmm = { type: "pubkey"; }, { - name: "position"; - type: "pubkey"; + name: "tradeDirection"; + type: "u8"; }, { - name: "owner"; - type: "pubkey"; + name: "hasReferral"; + type: "bool"; }, { name: "params"; type: { defined: { - name: "removeLiquidityParameters"; + name: "swapParameters"; }; }; }, { - name: "tokenAAmount"; + name: "swapResult"; + type: { + defined: { + name: "swapResult"; + }; + }; + }, + { + name: "actualAmountIn"; type: "u64"; }, { - name: "tokenBAmount"; + name: "currentTimestamp"; type: "u64"; } ]; }; }, { - name: "evtSetPoolStatus"; + name: "evtSwap2"; type: { kind: "struct"; fields: [ @@ -4523,23 +4742,11 @@ export type CpAmm = { type: "pubkey"; }, { - name: "status"; + name: "tradeDirection"; type: "u8"; - } - ]; - }; - }, - { - name: "evtSwap"; - type: { - kind: "struct"; - fields: [ - { - name: "pool"; - type: "pubkey"; }, { - name: "tradeDirection"; + name: "collectFeeMode"; type: "u8"; }, { @@ -4550,7 +4757,7 @@ export type CpAmm = { name: "params"; type: { defined: { - name: "swapParameters"; + name: "swapParameters2"; }; }; }, @@ -4558,17 +4765,33 @@ export type CpAmm = { name: "swapResult"; type: { defined: { - name: "swapResult"; + name: "swapResult2"; }; }; }, { - name: "actualAmountIn"; + name: "includedTransferFeeAmountIn"; + type: "u64"; + }, + { + name: "includedTransferFeeAmountOut"; + type: "u64"; + }, + { + name: "excludedTransferFeeAmountOut"; type: "u64"; }, { name: "currentTimestamp"; type: "u64"; + }, + { + name: "reserveAAmount"; + type: "u64"; + }, + { + name: "reserveBAmount"; + type: "u64"; } ]; }; @@ -4863,12 +5086,17 @@ export type CpAmm = { docs: ["pool type"]; type: "u8"; }, + { + name: "version"; + docs: [ + "pool version, 0: max_fee is still capped at 50%, 1: max_fee is capped at 99%" + ]; + type: "u8"; + }, { name: "padding0"; docs: ["padding"]; - type: { - array: ["u8", 2]; - }; + type: "u8"; }, { name: "feeAPerLiquidity"; @@ -4942,19 +5170,11 @@ export type CpAmm = { }; }, { - name: "protocolFeePercent"; - docs: ["Protocol trade fee percent"]; - type: "u8"; - }, - { - name: "partnerFeePercent"; - docs: ["partner fee percent"]; - type: "u8"; - }, - { - name: "referralFeePercent"; - docs: ["referral fee percent"]; - type: "u8"; + name: "padding"; + docs: ["padding"]; + type: { + array: ["u8", 3]; + }; }, { name: "dynamicFee"; @@ -5361,6 +5581,155 @@ export type CpAmm = { ]; }; }, + { + 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: "splitPositionParameters2"; + type: { + kind: "struct"; + fields: [ + { + name: "unlockedLiquidityNumerator"; + type: "u32"; + }, + { + name: "permanentLockedLiquidityNumerator"; + type: "u32"; + }, + { + name: "feeANumerator"; + type: "u32"; + }, + { + name: "feeBNumerator"; + type: "u32"; + }, + { + name: "reward0Numerator"; + type: "u32"; + }, + { + name: "reward1Numerator"; + type: "u32"; + } + ]; + }; + }, { name: "staticConfigParameters"; type: { @@ -5417,6 +5786,33 @@ export type CpAmm = { ]; }; }, + { + 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"]; @@ -5450,6 +5846,50 @@ export type CpAmm = { ]; }; }, + { + 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: "partnerFee"; + type: "u64"; + }, + { + name: "referralFee"; + type: "u64"; + } + ]; + }; + }, { name: "tokenBadge"; docs: ["Parameter that set by the protocol"]; diff --git a/tests/common/idl/dlmm.json b/tests/common/idl/dlmm.json index 24d3d6d..d53eb87 100644 --- a/tests/common/idl/dlmm.json +++ b/tests/common/idl/dlmm.json @@ -1,7624 +1,11126 @@ { - "address": "LbVRzDTvBDEcrthxfZ4RL6yiq3uZw8bS6MwtdY6UhFQ", - "metadata": { - "name": "lb_clmm", - "version": "0.9.1", - "spec": "0.1.0" - }, - "instructions": [ - { - "name": "initialize_lb_pair", - "discriminator": [ - 45, - 154, - 237, - 210, - 221, - 15, - 166, - 92 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "token_mint_x" - }, - { - "name": "token_mint_y" - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "oracle", - "writable": true - }, - { - "name": "preset_parameter" - }, - { - "name": "funder", - "writable": true, - "signer": true - }, - { - "name": "token_program" - }, - { - "name": "system_program" - }, - { - "name": "rent" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "active_id", - "type": "i32" - }, - { - "name": "bin_step", - "type": "u16" + "address": "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo", + "metadata": { + "name": "lb_clmm", + "version": "0.10.1", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "add_liquidity", + "discriminator": [ + 181, + 157, + 89, + 67, + 143, + 182, + 52, + 72 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token_x", + "writable": true + }, + { + "name": "user_token_y", + "writable": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "initialize_permission_lb_pair", - "discriminator": [ - 108, - 102, - 213, - 85, - 251, - 3, - 53, - 21 - ], - "accounts": [ - { - "name": "base", - "signer": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "token_mint_x" - }, - { - "name": "token_mint_y" - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "oracle", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "token_badge_x", - "optional": true - }, - { - "name": "token_badge_y", - "optional": true - }, - { - "name": "token_program_x" - }, - { - "name": "token_program_y" - }, - { - "name": "system_program" - }, - { - "name": "rent" - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "liquidity_parameter", + "type": { + "defined": { + "name": "LiquidityParameter" + } } - ], - "args": [ - { - "name": "ix_data", - "type": { - "defined": { - "name": "InitPermissionPairIx" + } + ] + }, + { + "name": "add_liquidity2", + "discriminator": [ + 228, + 162, + 78, + 28, + 70, + 219, + 116, + 115 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token_x", + "writable": true + }, + { + "name": "user_token_y", + "writable": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_x_program" + }, + { + "name": "token_y_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": "liquidity_parameter", + "type": { + "defined": { + "name": "LiquidityParameter" } } - ] - }, - { - "name": "initialize_customizable_permissionless_lb_pair", - "discriminator": [ - 46, - 39, - 41, - 135, - 111, - 183, - 200, - 64 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "token_mint_x" - }, - { - "name": "token_mint_y" - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "oracle", - "writable": true - }, - { - "name": "user_token_x" - }, - { - "name": "funder", - "writable": true, - "signer": true - }, - { - "name": "token_program" - }, - { - "name": "system_program" - }, - { - "name": "user_token_y" - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "CustomizableParams" + } + ] + }, + { + "name": "add_liquidity_by_strategy", + "discriminator": [ + 7, + 3, + 150, + 127, + 148, + 40, + 61, + 200 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token_x", + "writable": true + }, + { + "name": "user_token_y", + "writable": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "liquidity_parameter", + "type": { + "defined": { + "name": "LiquidityParameterByStrategy" } } - ] - }, - { - "name": "initialize_bin_array_bitmap_extension", - "discriminator": [ - 47, - 157, - 226, - 180, - 12, - 240, - 33, - 71 - ], - "accounts": [ - { - "name": "lb_pair" - }, - { - "name": "bin_array_bitmap_extension", - "docs": [ - "Initialize an account to store if a bin array is initialized." - ], - "writable": true - }, - { - "name": "funder", - "writable": true, - "signer": true - }, - { - "name": "system_program" - }, - { - "name": "rent" + } + ] + }, + { + "name": "add_liquidity_by_strategy2", + "discriminator": [ + 3, + 221, + 149, + 218, + 111, + 141, + 118, + 213 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token_x", + "writable": true + }, + { + "name": "user_token_y", + "writable": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_x_program" + }, + { + "name": "token_y_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 + ] + } + ] } - ], - "args": [] - }, - { - "name": "initialize_bin_array", - "discriminator": [ - 35, - 86, - 19, - 185, - 78, - 212, - 75, - 211 - ], - "accounts": [ - { - "name": "lb_pair" - }, - { - "name": "bin_array", - "writable": true - }, - { - "name": "funder", - "writable": true, - "signer": true - }, - { - "name": "system_program" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "liquidity_parameter", + "type": { + "defined": { + "name": "LiquidityParameterByStrategy" + } } - ], - "args": [ - { - "name": "index", - "type": "i64" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } } - ] - }, - { - "name": "add_liquidity", - "discriminator": [ - 181, - 157, - 89, - 67, - 143, - 182, - 52, - 72 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "user_token_x", - "writable": true - }, - { - "name": "user_token_y", - "writable": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, - { - "name": "sender", - "signer": true - }, - { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "liquidity_parameter", - "type": { - "defined": { - "name": "LiquidityParameter" + } + ] + }, + { + "name": "add_liquidity_by_strategy_one_side", + "discriminator": [ + 41, + 5, + 238, + 175, + 100, + 225, + 6, + 205 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token", + "writable": true + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "token_mint" + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "add_liquidity_by_weight", - "discriminator": [ - 28, - 140, - 238, - 99, - 231, - 162, - 21, - 149 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "user_token_x", - "writable": true - }, - { - "name": "user_token_y", - "writable": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, - { - "name": "sender", - "signer": true - }, - { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + ] } - ], - "args": [ - { - "name": "liquidity_parameter", - "type": { - "defined": { - "name": "LiquidityParameterByWeight" - } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "liquidity_parameter", + "type": { + "defined": { + "name": "LiquidityParameterByStrategyOneSide" } } - ] - }, - { - "name": "add_liquidity_by_strategy", - "discriminator": [ - 7, - 3, - 150, - 127, - 148, - 40, - 61, - 200 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "user_token_x", - "writable": true - }, - { - "name": "user_token_y", - "writable": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, - { - "name": "sender", - "signer": true - }, - { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "liquidity_parameter", - "type": { - "defined": { - "name": "LiquidityParameterByStrategy" + } + ] + }, + { + "name": "add_liquidity_by_weight", + "discriminator": [ + 28, + 140, + 238, + 99, + 231, + 162, + 21, + 149 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token_x", + "writable": true + }, + { + "name": "user_token_y", + "writable": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "add_liquidity_by_strategy_one_side", - "discriminator": [ - 41, - 5, - 238, - 175, - 100, - 225, - 6, - 205 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "user_token", - "writable": true - }, - { - "name": "reserve", - "writable": true - }, - { - "name": "token_mint" - }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, - { - "name": "sender", - "signer": true - }, - { - "name": "token_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "liquidity_parameter", + "type": { + "defined": { + "name": "LiquidityParameterByWeight" + } } - ], - "args": [ - { - "name": "liquidity_parameter", - "type": { - "defined": { - "name": "LiquidityParameterByStrategyOneSide" + } + ] + }, + { + "name": "add_liquidity_one_side", + "discriminator": [ + 94, + 155, + 103, + 151, + 70, + 95, + 220, + 165 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token", + "writable": true + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "token_mint" + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "add_liquidity_one_side", - "discriminator": [ - 94, - 155, - 103, - 151, - 70, - 95, - 220, - 165 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "user_token", - "writable": true - }, - { - "name": "reserve", - "writable": true - }, - { - "name": "token_mint" - }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, - { - "name": "sender", - "signer": true - }, - { - "name": "token_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "liquidity_parameter", + "type": { + "defined": { + "name": "LiquidityOneSideParameter" + } } - ], - "args": [ - { - "name": "liquidity_parameter", - "type": { - "defined": { - "name": "LiquidityOneSideParameter" + } + ] + }, + { + "name": "add_liquidity_one_side_precise", + "discriminator": [ + 161, + 194, + 103, + 84, + 171, + 71, + 250, + 154 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token", + "writable": true + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "token_mint" + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "parameter", + "type": { + "defined": { + "name": "AddLiquiditySingleSidePreciseParameter" } } - ] - }, - { - "name": "remove_liquidity", - "discriminator": [ - 80, - 85, - 209, - 72, - 24, - 206, - 177, - 108 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "user_token_x", - "writable": true - }, - { - "name": "user_token_y", - "writable": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, - { - "name": "sender", - "signer": true - }, - { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "bin_liquidity_removal", - "type": { - "vec": { - "defined": { - "name": "BinLiquidityReduction" - } + } + ] + }, + { + "name": "add_liquidity_one_side_precise2", + "discriminator": [ + 33, + 51, + 163, + 201, + 117, + 98, + 125, + 231 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token", + "writable": true + }, + { + "name": "reserve", + "writable": true + }, + { + "name": "token_mint" + }, + { + "name": "sender", + "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": "initialize_position", - "discriminator": [ - 219, - 192, - 234, - 71, - 190, - 191, - 102, - 80 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "position", - "writable": true, - "signer": true - }, - { - "name": "lb_pair" - }, - { - "name": "owner", - "signer": true - }, - { - "name": "system_program" - }, - { - "name": "rent" - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "liquidity_parameter", + "type": { + "defined": { + "name": "AddLiquiditySingleSidePreciseParameter2" + } } - ], - "args": [ - { - "name": "lower_bin_id", - "type": "i32" - }, - { - "name": "width", - "type": "i32" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } } - ] - }, - { - "name": "initialize_position_pda", - "discriminator": [ - 46, - 82, - 125, - 146, - 85, - 141, - 228, - 153 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "base", - "signer": true - }, - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair" - }, - { - "name": "owner", - "docs": [ - "owner" - ], - "signer": true - }, - { - "name": "system_program" - }, - { - "name": "rent" - }, - { - "name": "event_authority" - }, - { - "name": "program" + } + ] + }, + { + "name": "claim_fee", + "discriminator": [ + 169, + 32, + 79, + 137, + 136, + 232, + 70, + 137 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "sender", + "signer": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "user_token_x", + "writable": true + }, + { + "name": "user_token_y", + "writable": true + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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 + ] + } + ] } - ], - "args": [ - { - "name": "lower_bin_id", - "type": "i32" - }, - { - "name": "width", - "type": "i32" + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "claim_fee2", + "discriminator": [ + 112, + 191, + 101, + 171, + 28, + 144, + 127, + 187 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "sender", + "signer": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "user_token_x", + "writable": true + }, + { + "name": "user_token_y", + "writable": true + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_program_x" + }, + { + "name": "token_program_y" + }, + { + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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": "initialize_position_by_operator", - "discriminator": [ - 251, - 189, - 190, - 244, - 117, - 254, - 35, - 148 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "base", - "signer": true - }, - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair" - }, - { - "name": "owner" - }, - { - "name": "operator", - "docs": [ - "operator" - ], - "signer": true - }, - { - "name": "operator_token_x" - }, - { - "name": "owner_token_x" - }, - { - "name": "system_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "min_bin_id", + "type": "i32" + }, + { + "name": "max_bin_id", + "type": "i32" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } } - ], - "args": [ - { - "name": "lower_bin_id", - "type": "i32" - }, - { - "name": "width", - "type": "i32" - }, - { - "name": "fee_owner", - "type": "pubkey" - }, - { - "name": "lock_release_point", - "type": "u64" + } + ] + }, + { + "name": "claim_reward", + "discriminator": [ + 149, + 95, + 181, + 242, + 94, + 90, + 158, + 162 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "sender", + "signer": true + }, + { + "name": "reward_vault", + "writable": true + }, + { + "name": "reward_mint" + }, + { + "name": "user_token_account", + "writable": true + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "update_position_operator", - "discriminator": [ - 202, - 184, - 103, - 143, - 180, - 191, - 116, - 217 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "owner", - "signer": true - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "reward_index", + "type": "u64" + } + ] + }, + { + "name": "claim_reward2", + "discriminator": [ + 190, + 3, + 127, + 119, + 178, + 87, + 157, + 183 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "sender", + "signer": true + }, + { + "name": "reward_vault", + "writable": true + }, + { + "name": "reward_mint" + }, + { + "name": "user_token_account", + "writable": true + }, + { + "name": "token_program" + }, + { + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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 + ] + } + ] } - ], - "args": [ - { - "name": "operator", - "type": "pubkey" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "reward_index", + "type": "u64" + }, + { + "name": "min_bin_id", + "type": "i32" + }, + { + "name": "max_bin_id", + "type": "i32" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } } - ] - }, - { - "name": "swap", - "discriminator": [ - 248, - 198, - 158, - 145, - 225, - 117, - 135, - 200 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "optional": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "user_token_in", - "writable": true - }, - { - "name": "user_token_out", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "oracle", - "writable": true - }, - { - "name": "host_fee_in", - "writable": true, - "optional": true - }, - { - "name": "user", - "signer": true - }, - { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + } + ] + }, + { + "name": "close_claim_protocol_fee_operator", + "discriminator": [ + 8, + 41, + 87, + 35, + 80, + 48, + 121, + 26 + ], + "accounts": [ + { + "name": "claim_fee_operator", + "writable": true + }, + { + "name": "rent_receiver", + "writable": true + }, + { + "name": "admin", + "signer": true + } + ], + "args": [] + }, + { + "name": "close_position", + "discriminator": [ + 123, + 134, + 81, + 0, + 49, + 68, + 98, + 98 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "sender", + "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 + ] + } + ] } - ], - "args": [ - { - "name": "amount_in", - "type": "u64" - }, - { - "name": "min_amount_out", - "type": "u64" + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "close_position2", + "discriminator": [ + 174, + 90, + 35, + 115, + 186, + 40, + 147, + 226 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "sender", + "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": "swap_exact_out", - "discriminator": [ - 250, - 73, - 101, - 33, - 38, - 207, - 75, - 184 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "optional": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "user_token_in", - "writable": true - }, - { - "name": "user_token_out", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "oracle", - "writable": true - }, - { - "name": "host_fee_in", - "writable": true, - "optional": true - }, - { - "name": "user", - "signer": true - }, - { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "close_position_if_empty", + "discriminator": [ + 59, + 124, + 212, + 118, + 91, + 152, + 110, + 157 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "sender", + "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 + ] + } + ] } - ], - "args": [ - { - "name": "max_in_amount", - "type": "u64" - }, - { - "name": "out_amount", - "type": "u64" + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "close_preset_parameter", + "discriminator": [ + 4, + 148, + 145, + 100, + 134, + 26, + 181, + 61 + ], + "accounts": [ + { + "name": "preset_parameter", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "rent_receiver", + "writable": true + } + ], + "args": [] + }, + { + "name": "close_preset_parameter2", + "discriminator": [ + 39, + 25, + 95, + 107, + 116, + 17, + 115, + 28 + ], + "accounts": [ + { + "name": "preset_parameter", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "rent_receiver", + "writable": true + } + ], + "args": [] + }, + { + "name": "close_token_badge", + "discriminator": [ + 108, + 146, + 86, + 110, + 179, + 254, + 10, + 104 + ], + "accounts": [ + { + "name": "token_badge", + "writable": true + }, + { + "name": "rent_receiver", + "writable": true + }, + { + "name": "admin", + "signer": true + } + ], + "args": [] + }, + { + "name": "create_claim_protocol_fee_operator", + "discriminator": [ + 51, + 19, + 150, + 252, + 105, + 157, + 48, + 91 + ], + "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": "swap_with_price_impact", - "discriminator": [ - 56, - 173, - 230, - 208, - 173, - 228, - 156, - 205 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "optional": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "user_token_in", - "writable": true - }, - { - "name": "user_token_out", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "oracle", - "writable": true - }, - { - "name": "host_fee_in", - "writable": true, - "optional": true - }, - { - "name": "user", - "signer": true - }, - { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "operator" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "decrease_position_length", + "discriminator": [ + 194, + 219, + 136, + 32, + 25, + 96, + 105, + 37 + ], + "accounts": [ + { + "name": "rent_receiver", + "writable": true + }, + { + "name": "position", + "writable": true + }, + { + "name": "owner", + "signer": true, + "relations": [ + "position" + ] + }, + { + "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 + ] + } + ] } - ], - "args": [ - { - "name": "amount_in", - "type": "u64" - }, - { - "name": "active_id", - "type": { - "option": "i32" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "length_to_remove", + "type": "u16" + }, + { + "name": "side", + "type": "u8" + } + ] + }, + { + "name": "for_idl_type_generation_do_not_call", + "discriminator": [ + 180, + 105, + 69, + 80, + 95, + 50, + 73, + 108 + ], + "accounts": [ + { + "name": "dummy_zc_account" + } + ], + "args": [ + { + "name": "_ix", + "type": { + "defined": { + "name": "DummyIx" } - }, - { - "name": "max_price_impact_bps", - "type": "u16" - } - ] - }, - { - "name": "withdraw_protocol_fee", - "discriminator": [ - 158, - 201, - 158, - 189, - 33, - 93, - 162, - 103 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "receiver_token_x", - "writable": true - }, - { - "name": "receiver_token_y", - "writable": true - }, - { - "name": "claim_fee_operator" - }, - { - "name": "operator", - "docs": [ - "operator" - ], - "signer": true - }, - { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "memo_program" } - ], - "args": [ - { - "name": "amount_x", - "type": "u64" - }, - { - "name": "amount_y", - "type": "u64" - }, - { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" + } + ] + }, + { + "name": "fund_reward", + "discriminator": [ + 188, + 50, + 249, + 165, + 93, + 151, + 38, + 63 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array" + ] + }, + { + "name": "reward_vault", + "writable": true + }, + { + "name": "reward_mint" + }, + { + "name": "funder_token_account", + "writable": true + }, + { + "name": "funder", + "signer": true + }, + { + "name": "bin_array", + "writable": 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": "u64" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "carry_forward", + "type": "bool" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" } } - ] - }, - { - "name": "initialize_reward", - "discriminator": [ - 95, - 135, - 192, - 196, - 242, - 129, - 230, - 68 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "reward_vault", - "writable": true - }, - { - "name": "reward_mint" - }, - { - "name": "token_badge", - "optional": true - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "token_program" - }, - { - "name": "system_program" - }, - { - "name": "rent" - }, - { - "name": "event_authority" - }, - { - "name": "program" + } + ] + }, + { + "name": "go_to_a_bin", + "discriminator": [ + 146, + 72, + 174, + 224, + 40, + 253, + 84, + 174 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array_bitmap_extension", + "from_bin_array", + "to_bin_array" + ] + }, + { + "name": "bin_array_bitmap_extension", + "optional": true + }, + { + "name": "from_bin_array", + "optional": true + }, + { + "name": "to_bin_array", + "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 + ] + } + ] } - ], - "args": [ - { - "name": "reward_index", - "type": "u64" - }, - { - "name": "reward_duration", - "type": "u64" - }, - { - "name": "funder", - "type": "pubkey" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "bin_id", + "type": "i32" + } + ] + }, + { + "name": "increase_oracle_length", + "discriminator": [ + 190, + 61, + 125, + 87, + 103, + 79, + 158, + 173 + ], + "accounts": [ + { + "name": "oracle", + "writable": true + }, + { + "name": "funder", + "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": "fund_reward", - "discriminator": [ - 188, - 50, - 249, - 165, - 93, - 151, - 38, - 63 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "reward_vault", - "writable": true - }, - { - "name": "reward_mint" - }, - { - "name": "funder_token_account", - "writable": true - }, - { - "name": "funder", - "signer": true - }, - { - "name": "bin_array", - "writable": true - }, - { - "name": "token_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "length_to_add", + "type": "u64" + } + ] + }, + { + "name": "increase_position_length", + "discriminator": [ + 80, + 83, + 117, + 211, + 66, + 13, + 33, + 149 + ], + "accounts": [ + { + "name": "funder", + "writable": true, + "signer": true + }, + { + "name": "lb_pair", + "relations": [ + "position" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "owner", + "signer": true, + "relations": [ + "position" + ] + }, + { + "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 + ] + } + ] } - ], - "args": [ - { - "name": "reward_index", - "type": "u64" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "carry_forward", - "type": "bool" - }, - { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "length_to_add", + "type": "u16" + }, + { + "name": "side", + "type": "u8" + } + ] + }, + { + "name": "increase_position_length2", + "discriminator": [ + 255, + 210, + 204, + 71, + 115, + 137, + 225, + 113 + ], + "accounts": [ + { + "name": "funder", + "writable": true, + "signer": true + }, + { + "name": "lb_pair", + "relations": [ + "position" + ] + }, + { + "name": "position", + "writable": true + }, + { + "name": "owner", + "signer": true, + "relations": [ + "position" + ] + }, + { + "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": "update_reward_funder", - "discriminator": [ - 211, - 28, - 48, - 32, - 215, - 160, - 35, - 23 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "admin", - "signer": true - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "minimum_upper_bin_id", + "type": "i32" + } + ] + }, + { + "name": "initialize_bin_array", + "discriminator": [ + 35, + 86, + 19, + 185, + 78, + 212, + 75, + 211 + ], + "accounts": [ + { + "name": "lb_pair" + }, + { + "name": "bin_array", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 110, + 95, + 97, + 114, + 114, + 97, + 121 + ] + }, + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "arg", + "path": "index" + } + ] } - ], - "args": [ - { - "name": "reward_index", - "type": "u64" - }, - { - "name": "new_funder", - "type": "pubkey" + }, + { + "name": "funder", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "index", + "type": "i64" + } + ] + }, + { + "name": "initialize_bin_array_bitmap_extension", + "discriminator": [ + 47, + 157, + 226, + 180, + 12, + 240, + 33, + 71 + ], + "accounts": [ + { + "name": "lb_pair" + }, + { + "name": "bin_array_bitmap_extension", + "docs": [ + "Initialize an account to store if a bin array is initialized." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 116, + 109, + 97, + 112 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] } - ] - }, - { - "name": "update_reward_duration", - "discriminator": [ - 138, - 174, - 196, - 169, - 213, - 235, - 254, - 107 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "admin", - "signer": true - }, - { - "name": "bin_array", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "funder", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "initialize_customizable_permissionless_lb_pair", + "discriminator": [ + 46, + 39, + 41, + 135, + 111, + 183, + 200, + 64 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 116, + 109, + 97, + 112 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] } - ], - "args": [ - { - "name": "reward_index", - "type": "u64" - }, - { - "name": "new_duration", - "type": "u64" + }, + { + "name": "token_mint_x" + }, + { + "name": "token_mint_y" + }, + { + "name": "reserve_x", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_x" + } + ] } - ] - }, - { - "name": "claim_reward", - "discriminator": [ - 149, - 95, - 181, - 242, - 94, - 90, - 158, - 162 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "position", - "writable": true - }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, - { - "name": "sender", - "signer": true - }, - { - "name": "reward_vault", - "writable": true - }, - { - "name": "reward_mint" - }, - { - "name": "user_token_account", - "writable": true - }, - { - "name": "token_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "reserve_y", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_y" + } + ] } - ], - "args": [ - { - "name": "reward_index", - "type": "u64" + }, + { + "name": "oracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] } - ] - }, - { - "name": "claim_fee", - "discriminator": [ - 169, - 32, - 79, - 137, - 136, - 232, - 70, - 137 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "position", - "writable": true - }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, - { - "name": "sender", - "signer": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "user_token_x", - "writable": true - }, - { - "name": "user_token_y", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "token_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "user_token_x" + }, + { + "name": "funder", + "writable": true, + "signer": true + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "user_token_y" + }, + { + "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 + ] + } + ] } - ], - "args": [] - }, - { - "name": "close_position", - "discriminator": [ - 123, - 134, - 81, - 0, - 49, - 68, - 98, - 98 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, - { - "name": "sender", - "signer": true - }, - { - "name": "rent_receiver", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "update_base_fee_parameters", - "discriminator": [ - 75, - 168, - 223, - 161, - 16, - 195, - 3, - 47 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "admin", - "signer": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "fee_parameter", - "type": { - "defined": { - "name": "BaseFeeParameter" - } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "CustomizableParams" } } - ] - }, - { - "name": "update_dynamic_fee_parameters", - "discriminator": [ - 92, - 161, - 46, - 246, - 255, - 189, - 22, - 22 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "admin", - "signer": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "fee_parameter", - "type": { - "defined": { - "name": "DynamicFeeParameter" + } + ] + }, + { + "name": "initialize_customizable_permissionless_lb_pair2", + "discriminator": [ + 243, + 73, + 129, + 126, + 51, + 19, + 241, + 107 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 116, + 109, + 97, + 112 + ] + }, + { + "kind": "account", + "path": "lb_pair" } - } + ] } - ] - }, - { - "name": "increase_oracle_length", - "discriminator": [ - 190, - 61, - 125, - 87, - 103, - 79, - 158, - 173 - ], - "accounts": [ - { - "name": "oracle", - "writable": true - }, - { - "name": "funder", - "writable": true, - "signer": true - }, - { - "name": "system_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "token_mint_x" + }, + { + "name": "token_mint_y" + }, + { + "name": "reserve_x", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_x" + } + ] } - ], - "args": [ - { - "name": "length_to_add", - "type": "u64" + }, + { + "name": "reserve_y", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_y" + } + ] } - ] - }, - { - "name": "initialize_preset_parameter", - "discriminator": [ - 66, - 188, - 71, - 211, - 98, - 109, - 14, - 186 - ], - "accounts": [ - { - "name": "preset_parameter", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "system_program" - }, - { - "name": "rent" + }, + { + "name": "oracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] } - ], - "args": [ - { - "name": "ix", - "type": { - "defined": { - "name": "InitPresetParametersIx" + }, + { + "name": "user_token_x" + }, + { + "name": "funder", + "writable": true, + "signer": true + }, + { + "name": "token_badge_x", + "optional": true + }, + { + "name": "token_badge_y", + "optional": true + }, + { + "name": "token_program_x" + }, + { + "name": "token_program_y" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "user_token_y" + }, + { + "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": "CustomizableParams" } } - ] - }, - { - "name": "close_preset_parameter", - "discriminator": [ - 4, - 148, - 145, - 100, - 134, - 26, - 181, - 61 - ], - "accounts": [ - { - "name": "preset_parameter", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "rent_receiver", - "writable": true - } - ], - "args": [] - }, - { - "name": "close_preset_parameter2", - "discriminator": [ - 39, - 25, - 95, - 107, - 116, - 17, - 115, - 28 - ], - "accounts": [ - { - "name": "preset_parameter", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "rent_receiver", - "writable": true - } - ], - "args": [] - }, - { - "name": "remove_all_liquidity", - "discriminator": [ - 10, - 51, - 61, - 35, - 112, - 105, - 24, - 85 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "user_token_x", - "writable": true - }, - { - "name": "user_token_y", - "writable": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, - { - "name": "sender", - "signer": true - }, - { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + } + ] + }, + { + "name": "initialize_lb_pair", + "discriminator": [ + 45, + 154, + 237, + 210, + 221, + 15, + 166, + 92 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 116, + 109, + 97, + 112 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] } - ], - "args": [] - }, - { - "name": "set_pair_status", - "discriminator": [ - 67, - 248, - 231, - 137, - 154, - 149, - 217, - 174 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "admin", - "signer": true + }, + { + "name": "token_mint_x" + }, + { + "name": "token_mint_y" + }, + { + "name": "reserve_x", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_x" + } + ] } - ], - "args": [ - { - "name": "status", - "type": "u8" + }, + { + "name": "reserve_y", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_y" + } + ] } - ] - }, - { - "name": "migrate_position", - "discriminator": [ - 15, - 132, - 59, - 50, - 199, - 6, - 251, - 46 - ], - "accounts": [ - { - "name": "position_v2", - "writable": true, - "signer": true - }, - { - "name": "position_v1", - "writable": true - }, - { - "name": "lb_pair" - }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, - { - "name": "owner", - "writable": true, - "signer": true - }, - { - "name": "system_program" - }, - { - "name": "rent_receiver", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "oracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] } - ], - "args": [] - }, - { - "name": "migrate_bin_array", - "discriminator": [ - 17, - 23, - 159, - 211, - 101, - 184, - 41, - 241 - ], - "accounts": [ - { - "name": "lb_pair" - } - ], - "args": [] - }, - { - "name": "update_fees_and_rewards", - "discriminator": [ - 154, - 230, - 250, - 13, - 236, - 209, - 75, - 223 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, - { - "name": "owner", - "signer": true + }, + { + "name": "preset_parameter" + }, + { + "name": "funder", + "writable": true, + "signer": true + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "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 + ] + } + ] } - ], - "args": [] - }, - { - "name": "withdraw_ineligible_reward", - "discriminator": [ - 148, - 206, - 42, - 195, - 247, - 49, - 103, - 8 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "reward_vault", - "writable": true - }, - { - "name": "reward_mint" - }, - { - "name": "funder_token_account", - "writable": true - }, - { - "name": "funder", - "signer": true - }, - { - "name": "bin_array", - "writable": true - }, - { - "name": "token_program" - }, - { - "name": "memo_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "active_id", + "type": "i32" + }, + { + "name": "bin_step", + "type": "u16" + } + ] + }, + { + "name": "initialize_lb_pair2", + "discriminator": [ + 73, + 59, + 36, + 120, + 237, + 83, + 108, + 198 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 116, + 109, + 97, + 112 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] } - ], - "args": [ - { - "name": "reward_index", - "type": "u64" - }, - { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" + }, + { + "name": "token_mint_x" + }, + { + "name": "token_mint_y" + }, + { + "name": "reserve_x", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_x" } - } + ] } - ] - }, - { - "name": "set_activation_point", - "discriminator": [ - 91, - 249, - 15, - 165, - 26, - 129, - 254, - 125 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true + }, + { + "name": "reserve_y", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_y" + } + ] } - ], - "args": [ - { - "name": "activation_point", - "type": "u64" + }, + { + "name": "oracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] } - ] - }, - { - "name": "remove_liquidity_by_range", - "discriminator": [ - 26, - 82, - 102, - 152, - 240, - 74, - 105, - 26 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "user_token_x", - "writable": true - }, - { - "name": "user_token_y", - "writable": true - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "token_x_mint" - }, - { - "name": "token_y_mint" - }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, - { - "name": "sender", - "signer": true - }, - { - "name": "token_x_program" - }, - { - "name": "token_y_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" + }, + { + "name": "preset_parameter" + }, + { + "name": "funder", + "writable": true, + "signer": true + }, + { + "name": "token_badge_x", + "optional": true + }, + { + "name": "token_badge_y", + "optional": true + }, + { + "name": "token_program_x" + }, + { + "name": "token_program_y" + }, + { + "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": "InitializeLbPair2Params" + } + } + } + ] + }, + { + "name": "initialize_permission_lb_pair", + "discriminator": [ + 108, + 102, + 213, + 85, + 251, + 3, + 53, + 21 + ], + "accounts": [ + { + "name": "base", + "signer": true + }, + { + "name": "lb_pair", + "writable": true + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 116, + 109, + 97, + 112 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] + } + }, + { + "name": "token_mint_x" + }, + { + "name": "token_mint_y" + }, + { + "name": "reserve_x", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_x" + } + ] + } + }, + { + "name": "reserve_y", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "token_mint_y" + } + ] + } + }, + { + "name": "oracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "lb_pair" + } + ] + } + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "token_badge_x", + "optional": true + }, + { + "name": "token_badge_y", + "optional": true + }, + { + "name": "token_program_x" + }, + { + "name": "token_program_y" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "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": "ix_data", + "type": { + "defined": { + "name": "InitPermissionPairIx" + } + } + } + ] + }, + { + "name": "initialize_position", + "discriminator": [ + 219, + 192, + 234, + 71, + 190, + 191, + 102, + 80 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "position", + "writable": true, + "signer": true + }, + { + "name": "lb_pair" + }, + { + "name": "owner", + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "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": "lower_bin_id", + "type": "i32" + }, + { + "name": "width", + "type": "i32" + } + ] + }, + { + "name": "initialize_position2", + "discriminator": [ + 143, + 19, + 242, + 145, + 213, + 15, + 104, + 115 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "position", + "writable": true, + "signer": true + }, + { + "name": "lb_pair" + }, + { + "name": "owner", + "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": "lower_bin_id", + "type": "i32" + }, + { + "name": "width", + "type": "i32" + } + ] + }, + { + "name": "initialize_position_by_operator", + "discriminator": [ + 251, + 189, + 190, + 244, + 117, + 254, + 35, + 148 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "base", + "signer": true + }, + { + "name": "position", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 111, + 115, + 105, + 116, + 105, + 111, + 110 + ] + }, + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "base" + }, + { + "kind": "arg", + "path": "lower_bin_id" + }, + { + "kind": "arg", + "path": "width" + } + ] + } + }, + { + "name": "lb_pair" + }, + { + "name": "owner" + }, + { + "name": "operator", + "docs": [ + "operator" + ], + "signer": true + }, + { + "name": "operator_token_x" + }, + { + "name": "owner_token_x" + }, + { + "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": "lower_bin_id", + "type": "i32" + }, + { + "name": "width", + "type": "i32" + }, + { + "name": "fee_owner", + "type": "pubkey" + }, + { + "name": "lock_release_point", + "type": "u64" + } + ] + }, + { + "name": "initialize_position_pda", + "discriminator": [ + 46, + 82, + 125, + 146, + 85, + 141, + 228, + 153 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "base", + "signer": true + }, + { + "name": "position", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 111, + 115, + 105, + 116, + 105, + 111, + 110 + ] + }, + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "account", + "path": "base" + }, + { + "kind": "arg", + "path": "lower_bin_id" + }, + { + "kind": "arg", + "path": "width" + } + ] + } + }, + { + "name": "lb_pair" + }, + { + "name": "owner", + "docs": [ + "owner" + ], + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "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": "lower_bin_id", + "type": "i32" + }, + { + "name": "width", + "type": "i32" + } + ] + }, + { + "name": "initialize_preset_parameter", + "discriminator": [ + 66, + 188, + 71, + 211, + 98, + 109, + 14, + 186 + ], + "accounts": [ + { + "name": "preset_parameter", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 101, + 115, + 101, + 116, + 95, + 112, + 97, + 114, + 97, + 109, + 101, + 116, + 101, + 114 + ] + }, + { + "kind": "arg", + "path": "ix.bin_step" + }, + { + "kind": "arg", + "path": "ix.base_factor" + } + ] + } + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + } + ], + "args": [ + { + "name": "ix", + "type": { + "defined": { + "name": "InitPresetParametersIx" + } + } + } + ] + }, + { + "name": "initialize_preset_parameter2", + "discriminator": [ + 184, + 7, + 240, + 171, + 103, + 47, + 183, + 121 + ], + "accounts": [ + { + "name": "preset_parameter", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 101, + 115, + 101, + 116, + 95, + 112, + 97, + 114, + 97, + 109, + 101, + 116, + 101, + 114, + 50 + ] + }, + { + "kind": "arg", + "path": "ix.index" + } + ] + } + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "ix", + "type": { + "defined": { + "name": "InitPresetParameters2Ix" + } + } + } + ] + }, + { + "name": "initialize_reward", + "discriminator": [ + 95, + 135, + 192, + 196, + 242, + 129, + 230, + 68 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "reward_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "lb_pair" + }, + { + "kind": "arg", + "path": "reward_index" + } + ] + } + }, + { + "name": "reward_mint" + }, + { + "name": "token_badge", + "optional": true + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "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": "u64" + }, + { + "name": "reward_duration", + "type": "u64" + }, + { + "name": "funder", + "type": "pubkey" + } + ] + }, + { + "name": "initialize_token_badge", + "discriminator": [ + 253, + 77, + 205, + 95, + 27, + 224, + 89, + 223 + ], + "accounts": [ + { + "name": "token_mint" + }, + { + "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": "admin", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "migrate_bin_array", + "discriminator": [ + 17, + 23, + 159, + 211, + 101, + 184, + 41, + 241 + ], + "accounts": [ + { + "name": "lb_pair" + } + ], + "args": [] + }, + { + "name": "migrate_position", + "discriminator": [ + 15, + 132, + 59, + 50, + 199, + 6, + 251, + 46 + ], + "accounts": [ + { + "name": "position_v2", + "writable": true, + "signer": true + }, + { + "name": "position_v1", + "writable": true + }, + { + "name": "lb_pair", + "relations": [ + "position_v1", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "owner", + "writable": true, + "signer": true, + "relations": [ + "position_v1" + ] + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "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": "rebalance_liquidity", + "discriminator": [ + 92, + 4, + 176, + 193, + 119, + 185, + 83, + 9 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token_x", + "writable": true + }, + { + "name": "user_token_y", + "writable": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "owner", + "signer": true, + "relations": [ + "position" + ] + }, + { + "name": "rent_payer", + "writable": true, + "signer": true + }, + { + "name": "token_x_program" + }, + { + "name": "token_y_program" + }, + { + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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": "RebalanceLiquidityParams" + } + } + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } + } + } + ] + }, + { + "name": "remove_all_liquidity", + "discriminator": [ + 10, + 51, + 61, + 35, + 112, + 105, + 24, + 85 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token_x", + "writable": true + }, + { + "name": "user_token_y", + "writable": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "remove_liquidity", + "discriminator": [ + 80, + 85, + 209, + 72, + 24, + 206, + 177, + 108 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token_x", + "writable": true + }, + { + "name": "user_token_y", + "writable": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "bin_liquidity_removal", + "type": { + "vec": { + "defined": { + "name": "BinLiquidityReduction" + } + } + } + } + ] + }, + { + "name": "remove_liquidity2", + "discriminator": [ + 230, + 215, + 82, + 127, + 241, + 101, + 227, + 146 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token_x", + "writable": true + }, + { + "name": "user_token_y", + "writable": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_x_program" + }, + { + "name": "token_y_program" + }, + { + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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": "bin_liquidity_removal", + "type": { + "vec": { + "defined": { + "name": "BinLiquidityReduction" + } + } + } + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } + } + } + ] + }, + { + "name": "remove_liquidity_by_range", + "discriminator": [ + 26, + 82, + 102, + 152, + 240, + 74, + 105, + 26 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token_x", + "writable": true + }, + { + "name": "user_token_y", + "writable": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "from_bin_id", + "type": "i32" + }, + { + "name": "to_bin_id", + "type": "i32" + }, + { + "name": "bps_to_remove", + "type": "u16" + } + ] + }, + { + "name": "remove_liquidity_by_range2", + "discriminator": [ + 204, + 2, + 195, + 145, + 53, + 145, + 145, + 205 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "writable": true, + "optional": true + }, + { + "name": "user_token_x", + "writable": true + }, + { + "name": "user_token_y", + "writable": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "sender", + "signer": true + }, + { + "name": "token_x_program" + }, + { + "name": "token_y_program" + }, + { + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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": "from_bin_id", + "type": "i32" + }, + { + "name": "to_bin_id", + "type": "i32" + }, + { + "name": "bps_to_remove", + "type": "u16" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } + } + } + ] + }, + { + "name": "set_activation_point", + "discriminator": [ + 91, + 249, + 15, + 165, + 26, + 129, + 254, + 125 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true + } + ], + "args": [ + { + "name": "activation_point", + "type": "u64" + } + ] + }, + { + "name": "set_pair_status", + "discriminator": [ + 67, + 248, + 231, + 137, + 154, + 149, + 217, + 174 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "admin", + "signer": true + } + ], + "args": [ + { + "name": "status", + "type": "u8" + } + ] + }, + { + "name": "set_pair_status_permissionless", + "discriminator": [ + 78, + 59, + 152, + 211, + 70, + 183, + 46, + 208 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "creator", + "signer": true, + "relations": [ + "lb_pair" + ] + } + ], + "args": [ + { + "name": "status", + "type": "u8" + } + ] + }, + { + "name": "set_pre_activation_duration", + "discriminator": [ + 165, + 61, + 201, + 244, + 130, + 159, + 22, + 100 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "creator", + "signer": true, + "relations": [ + "lb_pair" + ] + } + ], + "args": [ + { + "name": "pre_activation_duration", + "type": "u64" + } + ] + }, + { + "name": "set_pre_activation_swap_address", + "discriminator": [ + 57, + 139, + 47, + 123, + 216, + 80, + 223, + 10 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "creator", + "signer": true, + "relations": [ + "lb_pair" + ] + } + ], + "args": [ + { + "name": "pre_activation_swap_address", + "type": "pubkey" + } + ] + }, + { + "name": "swap", + "discriminator": [ + 248, + 198, + 158, + 145, + 225, + 117, + 135, + 200 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "optional": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "user_token_in", + "writable": true + }, + { + "name": "user_token_out", + "writable": true + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "oracle", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "host_fee_in", + "writable": true, + "optional": true + }, + { + "name": "user", + "signer": true + }, + { + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "amount_in", + "type": "u64" + }, + { + "name": "min_amount_out", + "type": "u64" + } + ] + }, + { + "name": "swap2", + "discriminator": [ + 65, + 75, + 63, + 76, + 235, + 91, + 91, + 136 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "optional": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "user_token_in", + "writable": true + }, + { + "name": "user_token_out", + "writable": true + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "oracle", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "host_fee_in", + "writable": true, + "optional": true + }, + { + "name": "user", + "signer": true + }, + { + "name": "token_x_program" + }, + { + "name": "token_y_program" + }, + { + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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": "amount_in", + "type": "u64" + }, + { + "name": "min_amount_out", + "type": "u64" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } + } + } + ] + }, + { + "name": "swap_exact_out", + "discriminator": [ + 250, + 73, + 101, + 33, + 38, + 207, + 75, + 184 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "optional": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "user_token_in", + "writable": true + }, + { + "name": "user_token_out", + "writable": true + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "oracle", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "host_fee_in", + "writable": true, + "optional": true + }, + { + "name": "user", + "signer": true + }, + { + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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_in_amount", + "type": "u64" + }, + { + "name": "out_amount", + "type": "u64" + } + ] + }, + { + "name": "swap_exact_out2", + "discriminator": [ + 43, + 215, + 247, + 132, + 137, + 60, + 243, + 81 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "optional": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "user_token_in", + "writable": true + }, + { + "name": "user_token_out", + "writable": true + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "oracle", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "host_fee_in", + "writable": true, + "optional": true + }, + { + "name": "user", + "signer": true + }, + { + "name": "token_x_program" + }, + { + "name": "token_y_program" + }, + { + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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_in_amount", + "type": "u64" + }, + { + "name": "out_amount", + "type": "u64" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } + } + } + ] + }, + { + "name": "swap_with_price_impact", + "discriminator": [ + 56, + 173, + 230, + 208, + 173, + 228, + 156, + 205 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "optional": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "user_token_in", + "writable": true + }, + { + "name": "user_token_out", + "writable": true + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "oracle", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "host_fee_in", + "writable": true, + "optional": true + }, + { + "name": "user", + "signer": true + }, + { + "name": "token_x_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "token_y_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "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": "amount_in", + "type": "u64" + }, + { + "name": "active_id", + "type": { + "option": "i32" + } + }, + { + "name": "max_price_impact_bps", + "type": "u16" + } + ] + }, + { + "name": "swap_with_price_impact2", + "discriminator": [ + 74, + 98, + 192, + 214, + 177, + 51, + 75, + 51 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array_bitmap_extension" + ] + }, + { + "name": "bin_array_bitmap_extension", + "optional": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "user_token_in", + "writable": true + }, + { + "name": "user_token_out", + "writable": true + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "oracle", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "host_fee_in", + "writable": true, + "optional": true + }, + { + "name": "user", + "signer": true + }, + { + "name": "token_x_program" + }, + { + "name": "token_y_program" + }, + { + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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": "amount_in", + "type": "u64" + }, + { + "name": "active_id", + "type": { + "option": "i32" + } + }, + { + "name": "max_price_impact_bps", + "type": "u16" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } } - ], - "args": [ - { - "name": "from_bin_id", - "type": "i32" - }, - { - "name": "to_bin_id", - "type": "i32" - }, - { - "name": "bps_to_remove", - "type": "u16" + } + ] + }, + { + "name": "update_base_fee_parameters", + "discriminator": [ + 75, + 168, + 223, + 161, + 16, + 195, + 3, + 47 + ], + "accounts": [ + { + "name": "lb_pair", + "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": "add_liquidity_one_side_precise", - "discriminator": [ - 161, - 194, - 103, - 84, - 171, - 71, - 250, - 154 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "user_token", - "writable": true - }, - { - "name": "reserve", - "writable": true - }, - { - "name": "token_mint" - }, - { - "name": "bin_array_lower", - "writable": true - }, - { - "name": "bin_array_upper", - "writable": true - }, + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "fee_parameter", + "type": { + "defined": { + "name": "BaseFeeParameter" + } + } + } + ] + }, + { + "name": "update_dynamic_fee_parameters", + "discriminator": [ + 92, + 161, + 46, + 246, + 255, + 189, + 22, + 22 + ], + "accounts": [ + { + "name": "lb_pair", + "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": "fee_parameter", + "type": { + "defined": { + "name": "DynamicFeeParameter" + } + } + } + ] + }, + { + "name": "update_fees_and_reward2", + "discriminator": [ + 32, + 142, + 184, + 154, + 103, + 65, + 184, + 88 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position" + ] + }, + { + "name": "owner", + "signer": true + } + ], + "args": [ + { + "name": "min_bin_id", + "type": "i32" + }, + { + "name": "max_bin_id", + "type": "i32" + } + ] + }, + { + "name": "update_fees_and_rewards", + "discriminator": [ + 154, + 230, + 250, + 13, + 236, + 209, + 75, + 223 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "lb_pair", + "writable": true, + "relations": [ + "position", + "bin_array_lower", + "bin_array_upper" + ] + }, + { + "name": "bin_array_lower", + "writable": true + }, + { + "name": "bin_array_upper", + "writable": true + }, + { + "name": "owner", + "signer": true + } + ], + "args": [] + }, + { + "name": "update_position_operator", + "discriminator": [ + 202, + 184, + 103, + 143, + 180, + 191, + 116, + 217 + ], + "accounts": [ + { + "name": "position", + "writable": true + }, + { + "name": "owner", + "signer": true, + "relations": [ + "position" + ] + }, + { + "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": "operator", + "type": "pubkey" + } + ] + }, + { + "name": "update_reward_duration", + "discriminator": [ + 138, + 174, + 196, + 169, + 213, + 235, + 254, + 107 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array" + ] + }, + { + "name": "admin", + "signer": true + }, + { + "name": "bin_array", + "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": "reward_index", + "type": "u64" + }, + { + "name": "new_duration", + "type": "u64" + } + ] + }, + { + "name": "update_reward_funder", + "discriminator": [ + 211, + 28, + 48, + 32, + 215, + 160, + 35, + 23 + ], + "accounts": [ + { + "name": "lb_pair", + "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": "reward_index", + "type": "u64" + }, + { + "name": "new_funder", + "type": "pubkey" + } + ] + }, + { + "name": "withdraw_ineligible_reward", + "discriminator": [ + 148, + 206, + 42, + 195, + 247, + 49, + 103, + 8 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true, + "relations": [ + "bin_array" + ] + }, + { + "name": "reward_vault", + "writable": true + }, + { + "name": "reward_mint" + }, + { + "name": "funder_token_account", + "writable": true + }, + { + "name": "funder", + "signer": true + }, + { + "name": "bin_array", + "writable": true + }, + { + "name": "token_program" + }, + { + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + }, + { + "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": "u64" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } + } + } + ] + }, + { + "name": "withdraw_protocol_fee", + "discriminator": [ + 158, + 201, + 158, + 189, + 33, + 93, + 162, + 103 + ], + "accounts": [ + { + "name": "lb_pair", + "writable": true + }, + { + "name": "reserve_x", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "reserve_y", + "writable": true, + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_x_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "token_y_mint", + "relations": [ + "lb_pair" + ] + }, + { + "name": "receiver_token_x", + "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_x_program" + }, + { + "kind": "account", + "path": "token_x_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": "receiver_token_y", + "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_y_program" + }, + { + "kind": "account", + "path": "token_y_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" + }, + { + "name": "operator", + "docs": [ + "operator" + ], + "signer": true, + "relations": [ + "claim_fee_operator" + ] + }, + { + "name": "token_x_program" + }, + { + "name": "token_y_program" + }, + { + "name": "memo_program", + "address": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" + } + ], + "args": [ + { + "name": "max_amount_x", + "type": "u64" + }, + { + "name": "max_amount_y", + "type": "u64" + }, + { + "name": "remaining_accounts_info", + "type": { + "defined": { + "name": "RemainingAccountsInfo" + } + } + } + ] + } + ], + "accounts": [ + { + "name": "BinArray", + "discriminator": [ + 92, + 142, + 92, + 220, + 5, + 148, + 70, + 181 + ] + }, + { + "name": "BinArrayBitmapExtension", + "discriminator": [ + 80, + 111, + 124, + 113, + 55, + 237, + 18, + 5 + ] + }, + { + "name": "ClaimFeeOperator", + "discriminator": [ + 166, + 48, + 134, + 86, + 34, + 200, + 188, + 150 + ] + }, + { + "name": "DummyZcAccount", + "discriminator": [ + 94, + 107, + 238, + 80, + 208, + 48, + 180, + 8 + ] + }, + { + "name": "LbPair", + "discriminator": [ + 33, + 11, + 49, + 98, + 181, + 101, + 177, + 13 + ] + }, + { + "name": "Oracle", + "discriminator": [ + 139, + 194, + 131, + 179, + 140, + 179, + 229, + 244 + ] + }, + { + "name": "Position", + "discriminator": [ + 170, + 188, + 143, + 228, + 122, + 64, + 247, + 208 + ] + }, + { + "name": "PositionV2", + "discriminator": [ + 117, + 176, + 212, + 199, + 245, + 180, + 133, + 182 + ] + }, + { + "name": "PresetParameter", + "discriminator": [ + 242, + 62, + 244, + 34, + 181, + 112, + 58, + 170 + ] + }, + { + "name": "PresetParameter2", + "discriminator": [ + 171, + 236, + 148, + 115, + 162, + 113, + 222, + 174 + ] + }, + { + "name": "TokenBadge", + "discriminator": [ + 116, + 219, + 204, + 229, + 249, + 116, + 255, + 150 + ] + } + ], + "events": [ + { + "name": "AddLiquidity", + "discriminator": [ + 31, + 94, + 125, + 90, + 227, + 52, + 61, + 186 + ] + }, + { + "name": "ClaimFee", + "discriminator": [ + 75, + 122, + 154, + 48, + 140, + 74, + 123, + 163 + ] + }, + { + "name": "ClaimFee2", + "discriminator": [ + 232, + 171, + 242, + 97, + 58, + 77, + 35, + 45 + ] + }, + { + "name": "ClaimReward", + "discriminator": [ + 148, + 116, + 134, + 204, + 22, + 171, + 85, + 95 + ] + }, + { + "name": "ClaimReward2", + "discriminator": [ + 27, + 143, + 244, + 33, + 80, + 43, + 110, + 146 + ] + }, + { + "name": "CompositionFee", + "discriminator": [ + 128, + 151, + 123, + 106, + 17, + 102, + 113, + 142 + ] + }, + { + "name": "DecreasePositionLength", + "discriminator": [ + 52, + 118, + 235, + 85, + 172, + 169, + 15, + 128 + ] + }, + { + "name": "DynamicFeeParameterUpdate", + "discriminator": [ + 88, + 88, + 178, + 135, + 194, + 146, + 91, + 243 + ] + }, + { + "name": "FeeParameterUpdate", + "discriminator": [ + 48, + 76, + 241, + 117, + 144, + 215, + 242, + 44 + ] + }, + { + "name": "FundReward", + "discriminator": [ + 246, + 228, + 58, + 130, + 145, + 170, + 79, + 204 + ] + }, + { + "name": "GoToABin", + "discriminator": [ + 59, + 138, + 76, + 68, + 138, + 131, + 176, + 67 + ] + }, + { + "name": "IncreaseObservation", + "discriminator": [ + 99, + 249, + 17, + 121, + 166, + 156, + 207, + 215 + ] + }, + { + "name": "IncreasePositionLength", + "discriminator": [ + 157, + 239, + 42, + 204, + 30, + 56, + 223, + 46 + ] + }, + { + "name": "InitializeReward", + "discriminator": [ + 211, + 153, + 88, + 62, + 149, + 60, + 177, + 70 + ] + }, + { + "name": "LbPairCreate", + "discriminator": [ + 185, + 74, + 252, + 125, + 27, + 215, + 188, + 111 + ] + }, + { + "name": "PositionClose", + "discriminator": [ + 255, + 196, + 16, + 107, + 28, + 202, + 53, + 128 + ] + }, + { + "name": "PositionCreate", + "discriminator": [ + 144, + 142, + 252, + 84, + 157, + 53, + 37, + 121 + ] + }, + { + "name": "Rebalancing", + "discriminator": [ + 0, + 109, + 117, + 179, + 61, + 91, + 199, + 200 + ] + }, + { + "name": "RemoveLiquidity", + "discriminator": [ + 116, + 244, + 97, + 232, + 103, + 31, + 152, + 58 + ] + }, + { + "name": "Swap", + "discriminator": [ + 81, + 108, + 227, + 190, + 205, + 208, + 10, + 196 + ] + }, + { + "name": "UpdatePositionLockReleasePoint", + "discriminator": [ + 133, + 214, + 66, + 224, + 64, + 12, + 7, + 191 + ] + }, + { + "name": "UpdatePositionOperator", + "discriminator": [ + 39, + 115, + 48, + 204, + 246, + 47, + 66, + 57 + ] + }, + { + "name": "UpdateRewardDuration", + "discriminator": [ + 223, + 245, + 224, + 153, + 49, + 29, + 163, + 172 + ] + }, + { + "name": "UpdateRewardFunder", + "discriminator": [ + 224, + 178, + 174, + 74, + 252, + 165, + 85, + 180 + ] + }, + { + "name": "WithdrawIneligibleReward", + "discriminator": [ + 231, + 189, + 65, + 149, + 102, + 215, + 154, + 244 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "InvalidStartBinIndex", + "msg": "Invalid start bin index" + }, + { + "code": 6001, + "name": "InvalidBinId", + "msg": "Invalid bin id" + }, + { + "code": 6002, + "name": "InvalidInput", + "msg": "Invalid input data" + }, + { + "code": 6003, + "name": "ExceededAmountSlippageTolerance", + "msg": "Exceeded amount slippage tolerance" + }, + { + "code": 6004, + "name": "ExceededBinSlippageTolerance", + "msg": "Exceeded bin slippage tolerance" + }, + { + "code": 6005, + "name": "CompositionFactorFlawed", + "msg": "Composition factor flawed" + }, + { + "code": 6006, + "name": "NonPresetBinStep", + "msg": "Non preset bin step" + }, + { + "code": 6007, + "name": "ZeroLiquidity", + "msg": "Zero liquidity" + }, + { + "code": 6008, + "name": "InvalidPosition", + "msg": "Invalid position" + }, + { + "code": 6009, + "name": "BinArrayNotFound", + "msg": "Bin array not found" + }, + { + "code": 6010, + "name": "InvalidTokenMint", + "msg": "Invalid token mint" + }, + { + "code": 6011, + "name": "InvalidAccountForSingleDeposit", + "msg": "Invalid account for single deposit" + }, + { + "code": 6012, + "name": "PairInsufficientLiquidity", + "msg": "Pair insufficient liquidity" + }, + { + "code": 6013, + "name": "InvalidFeeOwner", + "msg": "Invalid fee owner" + }, + { + "code": 6014, + "name": "InvalidFeeWithdrawAmount", + "msg": "Invalid fee withdraw amount" + }, + { + "code": 6015, + "name": "InvalidAdmin", + "msg": "Invalid admin" + }, + { + "code": 6016, + "name": "IdenticalFeeOwner", + "msg": "Identical fee owner" + }, + { + "code": 6017, + "name": "InvalidBps", + "msg": "Invalid basis point" + }, + { + "code": 6018, + "name": "MathOverflow", + "msg": "Math operation overflow" + }, + { + "code": 6019, + "name": "TypeCastFailed", + "msg": "Type cast error" + }, + { + "code": 6020, + "name": "InvalidRewardIndex", + "msg": "Invalid reward index" + }, + { + "code": 6021, + "name": "InvalidRewardDuration", + "msg": "Invalid reward duration" + }, + { + "code": 6022, + "name": "RewardInitialized", + "msg": "Reward already initialized" + }, + { + "code": 6023, + "name": "RewardUninitialized", + "msg": "Reward not initialized" + }, + { + "code": 6024, + "name": "IdenticalFunder", + "msg": "Identical funder" + }, + { + "code": 6025, + "name": "RewardCampaignInProgress", + "msg": "Reward campaign in progress" + }, + { + "code": 6026, + "name": "IdenticalRewardDuration", + "msg": "Reward duration is the same" + }, + { + "code": 6027, + "name": "InvalidBinArray", + "msg": "Invalid bin array" + }, + { + "code": 6028, + "name": "NonContinuousBinArrays", + "msg": "Bin arrays must be continuous" + }, + { + "code": 6029, + "name": "InvalidRewardVault", + "msg": "Invalid reward vault" + }, + { + "code": 6030, + "name": "NonEmptyPosition", + "msg": "Position is not empty" + }, + { + "code": 6031, + "name": "UnauthorizedAccess", + "msg": "Unauthorized access" + }, + { + "code": 6032, + "name": "InvalidFeeParameter", + "msg": "Invalid fee parameter" + }, + { + "code": 6033, + "name": "MissingOracle", + "msg": "Missing oracle account" + }, + { + "code": 6034, + "name": "InsufficientSample", + "msg": "Insufficient observation sample" + }, + { + "code": 6035, + "name": "InvalidLookupTimestamp", + "msg": "Invalid lookup timestamp" + }, + { + "code": 6036, + "name": "BitmapExtensionAccountIsNotProvided", + "msg": "Bitmap extension account is not provided" + }, + { + "code": 6037, + "name": "CannotFindNonZeroLiquidityBinArrayId", + "msg": "Cannot find non-zero liquidity binArrayId" + }, + { + "code": 6038, + "name": "BinIdOutOfBound", + "msg": "Bin id out of bound" + }, + { + "code": 6039, + "name": "InsufficientOutAmount", + "msg": "Insufficient amount in for minimum out" + }, + { + "code": 6040, + "name": "InvalidPositionWidth", + "msg": "Invalid position width" + }, + { + "code": 6041, + "name": "ExcessiveFeeUpdate", + "msg": "Excessive fee update" + }, + { + "code": 6042, + "name": "PoolDisabled", + "msg": "Pool disabled" + }, + { + "code": 6043, + "name": "InvalidPoolType", + "msg": "Invalid pool type" + }, + { + "code": 6044, + "name": "ExceedMaxWhitelist", + "msg": "Whitelist for wallet is full" + }, + { + "code": 6045, + "name": "InvalidIndex", + "msg": "Invalid index" + }, + { + "code": 6046, + "name": "RewardNotEnded", + "msg": "Reward not ended" + }, + { + "code": 6047, + "name": "MustWithdrawnIneligibleReward", + "msg": "Must withdraw ineligible reward" + }, + { + "code": 6048, + "name": "UnauthorizedAddress", + "msg": "Unauthorized address" + }, + { + "code": 6049, + "name": "OperatorsAreTheSame", + "msg": "Cannot update because operators are the same" + }, + { + "code": 6050, + "name": "WithdrawToWrongTokenAccount", + "msg": "Withdraw to wrong token account" + }, + { + "code": 6051, + "name": "WrongRentReceiver", + "msg": "Wrong rent receiver" + }, + { + "code": 6052, + "name": "AlreadyPassActivationPoint", + "msg": "Already activated" + }, + { + "code": 6053, + "name": "ExceedMaxSwappedAmount", + "msg": "Swapped amount is exceeded max swapped amount" + }, + { + "code": 6054, + "name": "InvalidStrategyParameters", + "msg": "Invalid strategy parameters" + }, + { + "code": 6055, + "name": "LiquidityLocked", + "msg": "Liquidity locked" + }, + { + "code": 6056, + "name": "BinRangeIsNotEmpty", + "msg": "Bin range is not empty" + }, + { + "code": 6057, + "name": "NotExactAmountOut", + "msg": "Amount out is not matched with exact amount out" + }, + { + "code": 6058, + "name": "InvalidActivationType", + "msg": "Invalid activation type" + }, + { + "code": 6059, + "name": "InvalidActivationDuration", + "msg": "Invalid activation duration" + }, + { + "code": 6060, + "name": "MissingTokenAmountAsTokenLaunchProof", + "msg": "Missing token amount as token launch owner proof" + }, + { + "code": 6061, + "name": "InvalidQuoteToken", + "msg": "Quote token must be SOL or USDC" + }, + { + "code": 6062, + "name": "InvalidBinStep", + "msg": "Invalid bin step" + }, + { + "code": 6063, + "name": "InvalidBaseFee", + "msg": "Invalid base fee" + }, + { + "code": 6064, + "name": "InvalidPreActivationDuration", + "msg": "Invalid pre-activation duration" + }, + { + "code": 6065, + "name": "AlreadyPassPreActivationSwapPoint", + "msg": "Already pass pre-activation swap point" + }, + { + "code": 6066, + "name": "InvalidStatus", + "msg": "Invalid status" + }, + { + "code": 6067, + "name": "ExceededMaxOracleLength", + "msg": "Exceed max oracle length" + }, + { + "code": 6068, + "name": "InvalidMinimumLiquidity", + "msg": "Invalid minimum liquidity" + }, + { + "code": 6069, + "name": "NotSupportMint", + "msg": "Not support token_2022 mint extension" + }, + { + "code": 6070, + "name": "UnsupportedMintExtension", + "msg": "Unsupported mint extension" + }, + { + "code": 6071, + "name": "UnsupportNativeMintToken2022", + "msg": "Unsupported native mint token2022" + }, + { + "code": 6072, + "name": "UnmatchTokenMint", + "msg": "Unmatch token mint" + }, + { + "code": 6073, + "name": "UnsupportedTokenMint", + "msg": "Unsupported token mint" + }, + { + "code": 6074, + "name": "InsufficientRemainingAccounts", + "msg": "Insufficient remaining accounts" + }, + { + "code": 6075, + "name": "InvalidRemainingAccountSlice", + "msg": "Invalid remaining account slice" + }, + { + "code": 6076, + "name": "DuplicatedRemainingAccountTypes", + "msg": "Duplicated remaining account types" + }, + { + "code": 6077, + "name": "MissingRemainingAccountForTransferHook", + "msg": "Missing remaining account for transfer hook" + }, + { + "code": 6078, + "name": "NoTransferHookProgram", + "msg": "Remaining account was passed for transfer hook but there's no hook program" + }, + { + "code": 6079, + "name": "ZeroFundedAmount", + "msg": "Zero funded amount" + }, + { + "code": 6080, + "name": "InvalidSide", + "msg": "Invalid side" + }, + { + "code": 6081, + "name": "InvalidResizeLength", + "msg": "Invalid resize length" + }, + { + "code": 6082, + "name": "NotSupportAtTheMoment", + "msg": "Not support at the moment" + }, + { + "code": 6083, + "name": "InvalidRebalanceParameters", + "msg": "Invalid rebalance parameters" + }, + { + "code": 6084, + "name": "InvalidRewardAccounts", + "msg": "Invalid reward accounts" + }, + { + "code": 6085, + "name": "UndeterminedError", + "msg": "Undetermined error" + }, + { + "code": 6086, + "name": "ReallocExceedMaxLengthPerInstruction", + "msg": "Realloc exceed max length per instruction" + }, + { + "code": 6087, + "name": "InvalidBaseFeeMantissa", + "msg": "Mantissa cannot more than two significant digits" + }, + { + "code": 6088, + "name": "InvalidPositionOwner", + "msg": "Invalid position owner" + }, + { + "code": 6089, + "name": "InvalidPoolAddress", + "msg": "Invalid pool address" + } + ], + "types": [ + { + "name": "AccountsType", + "type": { + "kind": "enum", + "variants": [ { - "name": "sender", - "signer": true + "name": "TransferHookX" }, { - "name": "token_program" + "name": "TransferHookY" }, { - "name": "event_authority" + "name": "TransferHookReward" }, { - "name": "program" - } - ], - "args": [ - { - "name": "parameter", - "type": { - "defined": { - "name": "AddLiquiditySingleSidePreciseParameter" - } - } + "name": "TransferHookMultiReward", + "fields": [ + "u8" + ] } ] + } + }, + { + "name": "ActivationType", + "docs": [ + "Type of the activation" + ], + "repr": { + "kind": "rust" }, - { - "name": "go_to_a_bin", - "discriminator": [ - 146, - 72, - 174, - 224, - 40, - 253, - 84, - 174 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "optional": true - }, - { - "name": "from_bin_array", - "optional": true - }, - { - "name": "to_bin_array", - "optional": true - }, + "type": { + "kind": "enum", + "variants": [ { - "name": "event_authority" + "name": "Slot" }, { - "name": "program" - } - ], - "args": [ - { - "name": "bin_id", - "type": "i32" + "name": "Timestamp" } ] - }, - { - "name": "set_pre_activation_duration", - "discriminator": [ - 165, - 61, - 201, - 244, - 130, - 159, - 22, - 100 - ], - "accounts": [ + } + }, + { + "name": "AddLiquidity", + "type": { + "kind": "struct", + "fields": [ { "name": "lb_pair", - "writable": true + "type": "pubkey" }, { - "name": "creator", - "signer": true - } - ], - "args": [ - { - "name": "pre_activation_duration", - "type": "u64" - } - ] - }, - { - "name": "set_pre_activation_swap_address", - "discriminator": [ - 57, - 139, - 47, - 123, - 216, - 80, - 223, - 10 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true + "name": "from", + "type": "pubkey" }, { - "name": "creator", - "signer": true - } - ], - "args": [ - { - "name": "pre_activation_swap_address", + "name": "position", "type": "pubkey" - } - ] - }, - { - "name": "set_pair_status_permissionless", - "discriminator": [ - 78, - 59, - 152, - 211, - 70, - 183, - 46, - 208 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true }, { - "name": "creator", - "signer": true - } - ], - "args": [ + "name": "amounts", + "type": { + "array": [ + "u64", + 2 + ] + } + }, { - "name": "status", - "type": "u8" + "name": "active_bin_id", + "type": "i32" } ] - }, - { - "name": "initialize_token_badge", - "discriminator": [ - 253, - 77, - 205, - 95, - 27, - 224, - 89, - 223 - ], - "accounts": [ - { - "name": "token_mint" - }, - { - "name": "token_badge", - "writable": true - }, + } + }, + { + "name": "AddLiquidityParams", + "type": { + "kind": "struct", + "fields": [ { - "name": "admin", - "writable": true, - "signer": true + "name": "min_delta_id", + "type": "i32" }, { - "name": "system_program" - } - ], - "args": [] - }, - { - "name": "create_claim_protocol_fee_operator", - "discriminator": [ - 51, - 19, - 150, - 252, - 105, - 157, - 48, - 91 - ], - "accounts": [ - { - "name": "claim_fee_operator", - "writable": true + "name": "max_delta_id", + "type": "i32" }, { - "name": "operator" + "name": "x0", + "type": "u64" }, { - "name": "admin", - "writable": true, - "signer": true + "name": "y0", + "type": "u64" }, { - "name": "system_program" - } - ], - "args": [] - }, - { - "name": "close_claim_protocol_fee_operator", - "discriminator": [ - 8, - 41, - 87, - 35, - 80, - 48, - 121, - 26 - ], - "accounts": [ - { - "name": "claim_fee_operator", - "writable": true + "name": "delta_x", + "type": "u64" }, { - "name": "rent_receiver", - "writable": true + "name": "delta_y", + "type": "u64" }, { - "name": "admin", - "signer": true - } - ], - "args": [] - }, - { - "name": "initialize_preset_parameter2", - "discriminator": [ - 184, - 7, - 240, - 171, - 103, - 47, - 183, - 121 - ], - "accounts": [ - { - "name": "preset_parameter", - "writable": true + "name": "bit_flag", + "type": "u8" }, { - "name": "admin", - "writable": true, - "signer": true + "name": "favor_x_in_active_id", + "type": "bool" }, { - "name": "system_program" - } - ], - "args": [ - { - "name": "ix", + "name": "padding", "type": { - "defined": { - "name": "InitPresetParameters2Ix" - } + "array": [ + "u8", + 16 + ] } } ] - }, - { - "name": "initialize_lb_pair2", - "discriminator": [ - 73, - 59, - 36, - 120, - 237, - 83, - 108, - 198 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "token_mint_x" - }, - { - "name": "token_mint_y" - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "oracle", - "writable": true - }, - { - "name": "preset_parameter" - }, - { - "name": "funder", - "writable": true, - "signer": true - }, - { - "name": "token_badge_x", - "optional": true - }, - { - "name": "token_badge_y", - "optional": true - }, - { - "name": "token_program_x" - }, - { - "name": "token_program_y" - }, - { - "name": "system_program" - }, + } + }, + { + "name": "AddLiquiditySingleSidePreciseParameter", + "type": { + "kind": "struct", + "fields": [ { - "name": "event_authority" + "name": "bins", + "type": { + "vec": { + "defined": { + "name": "CompressedBinDepositAmount" + } + } + } }, { - "name": "program" + "name": "decompress_multiplier", + "type": "u64" } - ], - "args": [ + ] + } + }, + { + "name": "AddLiquiditySingleSidePreciseParameter2", + "type": { + "kind": "struct", + "fields": [ { - "name": "params", + "name": "bins", "type": { - "defined": { - "name": "InitializeLbPair2Params" + "vec": { + "defined": { + "name": "CompressedBinDepositAmount" + } } } - } - ] - }, - { - "name": "initialize_customizable_permissionless_lb_pair2", - "discriminator": [ - 243, - 73, - 129, - 126, - 51, - 19, - 241, - 107 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "token_mint_x" - }, - { - "name": "token_mint_y" - }, - { - "name": "reserve_x", - "writable": true - }, - { - "name": "reserve_y", - "writable": true - }, - { - "name": "oracle", - "writable": true - }, - { - "name": "user_token_x" - }, - { - "name": "funder", - "writable": true, - "signer": true - }, - { - "name": "token_badge_x", - "optional": true - }, - { - "name": "token_badge_y", - "optional": true - }, - { - "name": "token_program_x" }, { - "name": "token_program_y" + "name": "decompress_multiplier", + "type": "u64" }, { - "name": "system_program" - }, + "name": "max_amount", + "type": "u64" + } + ] + } + }, + { + "name": "BaseFeeParameter", + "type": { + "kind": "struct", + "fields": [ { - "name": "user_token_y" + "name": "protocol_share", + "docs": [ + "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + ], + "type": "u16" }, { - "name": "event_authority" + "name": "base_factor", + "docs": [ + "Base factor for base fee rate" + ], + "type": "u16" }, { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "CustomizableParams" - } - } + "name": "base_fee_power_factor", + "docs": [ + "Base fee power factor" + ], + "type": "u8" } ] + } + }, + { + "name": "Bin", + "serialization": "bytemuck", + "repr": { + "kind": "c" }, - { - "name": "claim_fee2", - "discriminator": [ - 112, - 191, - 101, - 171, - 28, - 144, - 127, - 187 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "position", - "writable": true - }, + "type": { + "kind": "struct", + "fields": [ { - "name": "sender", - "signer": true + "name": "amount_x", + "docs": [ + "Amount of token X in the bin. This already excluded protocol fees." + ], + "type": "u64" }, { - "name": "reserve_x", - "writable": true + "name": "amount_y", + "docs": [ + "Amount of token Y in the bin. This already excluded protocol fees." + ], + "type": "u64" }, { - "name": "reserve_y", - "writable": true + "name": "price", + "docs": [ + "Bin price" + ], + "type": "u128" }, { - "name": "user_token_x", - "writable": true + "name": "liquidity_supply", + "docs": [ + "Liquidities of the bin. This is the same as LP mint supply. q-number" + ], + "type": "u128" }, { - "name": "user_token_y", - "writable": true + "name": "reward_per_token_stored", + "docs": [ + "reward_a_per_token_stored" + ], + "type": { + "array": [ + "u128", + 2 + ] + } }, { - "name": "token_x_mint" + "name": "fee_amount_x_per_token_stored", + "docs": [ + "Swap fee amount of token X per liquidity deposited." + ], + "type": "u128" }, { - "name": "token_y_mint" + "name": "fee_amount_y_per_token_stored", + "docs": [ + "Swap fee amount of token Y per liquidity deposited." + ], + "type": "u128" }, { - "name": "token_program_x" + "name": "amount_x_in", + "docs": [ + "Total token X swap into the bin. Only used for tracking purpose." + ], + "type": "u128" }, { - "name": "token_program_y" - }, + "name": "amount_y_in", + "docs": [ + "Total token Y swap into he bin. Only used for tracking purpose." + ], + "type": "u128" + } + ] + } + }, + { + "name": "BinArray", + "docs": [ + "An account to contain a range of bin. For example: Bin 100 <-> 200.", + "For example:", + "BinArray index: 0 contains bin 0 <-> 599", + "index: 2 contains bin 600 <-> 1199, ..." + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "memo_program" + "name": "index", + "type": "i64" }, { - "name": "event_authority" + "name": "version", + "docs": [ + "Version of binArray" + ], + "type": "u8" }, { - "name": "program" - } - ], - "args": [ - { - "name": "min_bin_id", - "type": "i32" + "name": "_padding", + "type": { + "array": [ + "u8", + 7 + ] + } }, { - "name": "max_bin_id", - "type": "i32" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "remaining_accounts_info", + "name": "bins", "type": { - "defined": { - "name": "RemainingAccountsInfo" - } + "array": [ + { + "defined": { + "name": "Bin" + } + }, + 70 + ] } } ] + } + }, + { + "name": "BinArrayBitmapExtension", + "serialization": "bytemuck", + "repr": { + "kind": "c" }, - { - "name": "claim_reward2", - "discriminator": [ - 190, - 3, - 127, - 119, - 178, - 87, - 157, - 183 - ], - "accounts": [ + "type": { + "kind": "struct", + "fields": [ { "name": "lb_pair", - "writable": true - }, - { - "name": "position", - "writable": true - }, - { - "name": "sender", - "signer": true - }, - { - "name": "reward_vault", - "writable": true - }, - { - "name": "reward_mint" + "type": "pubkey" }, { - "name": "user_token_account", - "writable": true + "name": "positive_bin_array_bitmap", + "docs": [ + "Packed initialized bin array state for start_bin_index is positive" + ], + "type": { + "array": [ + { + "array": [ + "u64", + 8 + ] + }, + 12 + ] + } }, { - "name": "token_program" - }, + "name": "negative_bin_array_bitmap", + "docs": [ + "Packed initialized bin array state for start_bin_index is negative" + ], + "type": { + "array": [ + { + "array": [ + "u64", + 8 + ] + }, + 12 + ] + } + } + ] + } + }, + { + "name": "BinLiquidityDistribution", + "type": { + "kind": "struct", + "fields": [ { - "name": "memo_program" + "name": "bin_id", + "docs": [ + "Define the bin ID wish to deposit to." + ], + "type": "i32" }, { - "name": "event_authority" + "name": "distribution_x", + "docs": [ + "DistributionX (or distributionY) is the percentages of amountX (or amountY) you want to add to each bin." + ], + "type": "u16" }, { - "name": "program" + "name": "distribution_y", + "docs": [ + "DistributionX (or distributionY) is the percentages of amountX (or amountY) you want to add to each bin." + ], + "type": "u16" } - ], - "args": [ - { - "name": "reward_index", - "type": "u64" - }, + ] + } + }, + { + "name": "BinLiquidityDistributionByWeight", + "type": { + "kind": "struct", + "fields": [ { - "name": "min_bin_id", + "name": "bin_id", + "docs": [ + "Define the bin ID wish to deposit to." + ], "type": "i32" }, { - "name": "max_bin_id", + "name": "weight", + "docs": [ + "weight of liquidity distributed for this bin id" + ], + "type": "u16" + } + ] + } + }, + { + "name": "BinLiquidityReduction", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bin_id", "type": "i32" }, { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" - } - } + "name": "bps_to_remove", + "type": "u16" } ] - }, - { - "name": "add_liquidity2", - "discriminator": [ - 228, - 162, - 78, - 28, - 70, - 219, - 116, - 115 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, + } + }, + { + "name": "ClaimFee", + "type": { + "kind": "struct", + "fields": [ { "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "user_token_x", - "writable": true + "type": "pubkey" }, { - "name": "user_token_y", - "writable": true + "name": "position", + "type": "pubkey" }, { - "name": "reserve_x", - "writable": true + "name": "owner", + "type": "pubkey" }, { - "name": "reserve_y", - "writable": true + "name": "fee_x", + "type": "u64" }, { - "name": "token_x_mint" - }, + "name": "fee_y", + "type": "u64" + } + ] + } + }, + { + "name": "ClaimFee2", + "type": { + "kind": "struct", + "fields": [ { - "name": "token_y_mint" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "sender", - "signer": true + "name": "position", + "type": "pubkey" }, { - "name": "token_x_program" + "name": "owner", + "type": "pubkey" }, { - "name": "token_y_program" + "name": "fee_x", + "type": "u64" }, { - "name": "event_authority" + "name": "fee_y", + "type": "u64" }, { - "name": "program" + "name": "active_bin_id", + "type": "i32" } - ], - "args": [ + ] + } + }, + { + "name": "ClaimFeeOperator", + "docs": [ + "Parameter that set by the protocol" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "liquidity_parameter", - "type": { - "defined": { - "name": "LiquidityParameter" - } - } + "name": "operator", + "docs": [ + "operator" + ], + "type": "pubkey" }, { - "name": "remaining_accounts_info", + "name": "_padding", + "docs": [ + "Reserve" + ], "type": { - "defined": { - "name": "RemainingAccountsInfo" - } + "array": [ + "u8", + 128 + ] } } ] - }, - { - "name": "add_liquidity_by_strategy2", - "discriminator": [ - 3, - 221, - 149, - 218, - 111, - 141, - 118, - 213 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, + } + }, + { + "name": "ClaimReward", + "type": { + "kind": "struct", + "fields": [ { "name": "lb_pair", - "writable": true + "type": "pubkey" }, { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true + "name": "position", + "type": "pubkey" }, { - "name": "user_token_x", - "writable": true + "name": "owner", + "type": "pubkey" }, { - "name": "user_token_y", - "writable": true + "name": "reward_index", + "type": "u64" }, { - "name": "reserve_x", - "writable": true + "name": "total_reward", + "type": "u64" + } + ] + } + }, + { + "name": "ClaimReward2", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lb_pair", + "type": "pubkey" }, { - "name": "reserve_y", - "writable": true + "name": "position", + "type": "pubkey" }, { - "name": "token_x_mint" + "name": "owner", + "type": "pubkey" }, { - "name": "token_y_mint" + "name": "reward_index", + "type": "u64" }, { - "name": "sender", - "signer": true + "name": "total_reward", + "type": "u64" }, { - "name": "token_x_program" + "name": "active_bin_id", + "type": "i32" + } + ] + } + }, + { + "name": "CompositionFee", + "type": { + "kind": "struct", + "fields": [ + { + "name": "from", + "type": "pubkey" }, { - "name": "token_y_program" + "name": "bin_id", + "type": "i16" }, { - "name": "event_authority" + "name": "token_x_fee_amount", + "type": "u64" }, { - "name": "program" - } - ], - "args": [ + "name": "token_y_fee_amount", + "type": "u64" + }, { - "name": "liquidity_parameter", - "type": { - "defined": { - "name": "LiquidityParameterByStrategy" - } - } + "name": "protocol_token_x_fee_amount", + "type": "u64" }, { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" - } - } + "name": "protocol_token_y_fee_amount", + "type": "u64" } ] - }, - { - "name": "add_liquidity_one_side_precise2", - "discriminator": [ - 33, - 51, - 163, - 201, - 117, - 98, - 125, - 231 - ], - "accounts": [ + } + }, + { + "name": "CompressedBinDepositAmount", + "type": { + "kind": "struct", + "fields": [ { - "name": "position", - "writable": true + "name": "bin_id", + "type": "i32" }, { - "name": "lb_pair", - "writable": true - }, + "name": "amount", + "type": "u32" + } + ] + } + }, + { + "name": "CustomizableParams", + "type": { + "kind": "struct", + "fields": [ { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true + "name": "active_id", + "docs": [ + "Pool price" + ], + "type": "i32" }, { - "name": "user_token", - "writable": true + "name": "bin_step", + "docs": [ + "Bin step" + ], + "type": "u16" }, { - "name": "reserve", - "writable": true + "name": "base_factor", + "docs": [ + "Base factor" + ], + "type": "u16" }, { - "name": "token_mint" + "name": "activation_type", + "docs": [ + "Activation type. 0 = Slot, 1 = Time. Check ActivationType enum" + ], + "type": "u8" }, { - "name": "sender", - "signer": true + "name": "has_alpha_vault", + "docs": [ + "Whether the pool has an alpha vault" + ], + "type": "bool" }, { - "name": "token_program" + "name": "activation_point", + "docs": [ + "Decide when does the pool start trade. None = Now" + ], + "type": { + "option": "u64" + } }, { - "name": "event_authority" + "name": "creator_pool_on_off_control", + "docs": [ + "Pool creator have permission to enable/disable pool with restricted program validation. Only applicable for customizable permissionless pool." + ], + "type": "bool" }, { - "name": "program" - } - ], - "args": [ - { - "name": "liquidity_parameter", - "type": { - "defined": { - "name": "AddLiquiditySingleSidePreciseParameter2" - } - } + "name": "base_fee_power_factor", + "docs": [ + "Base fee power factor" + ], + "type": "u8" }, { - "name": "remaining_accounts_info", + "name": "padding", + "docs": [ + "Padding, for future use" + ], "type": { - "defined": { - "name": "RemainingAccountsInfo" - } + "array": [ + "u8", + 62 + ] } } ] - }, - { - "name": "remove_liquidity2", - "discriminator": [ - 230, - 215, - 82, - 127, - 241, - 101, - 227, - 146 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, + } + }, + { + "name": "DecreasePositionLength", + "type": { + "kind": "struct", + "fields": [ { "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true - }, - { - "name": "user_token_x", - "writable": true - }, - { - "name": "user_token_y", - "writable": true - }, - { - "name": "reserve_x", - "writable": true + "type": "pubkey" }, { - "name": "reserve_y", - "writable": true + "name": "position", + "type": "pubkey" }, { - "name": "token_x_mint" + "name": "owner", + "type": "pubkey" }, { - "name": "token_y_mint" + "name": "length_to_remove", + "type": "u16" }, { - "name": "sender", - "signer": true - }, + "name": "side", + "type": "u8" + } + ] + } + }, + { + "name": "DummyIx", + "type": { + "kind": "struct", + "fields": [ { - "name": "token_x_program" + "name": "_pair_status", + "type": { + "defined": { + "name": "PairStatus" + } + } }, { - "name": "token_y_program" + "name": "_pair_type", + "type": { + "defined": { + "name": "PairType" + } + } }, { - "name": "memo_program" + "name": "_activation_type", + "type": { + "defined": { + "name": "ActivationType" + } + } }, { - "name": "event_authority" + "name": "_token_program_flag", + "type": { + "defined": { + "name": "TokenProgramFlags" + } + } }, { - "name": "program" - } - ], - "args": [ - { - "name": "bin_liquidity_removal", + "name": "_resize_side", "type": { - "vec": { - "defined": { - "name": "BinLiquidityReduction" - } + "defined": { + "name": "ResizeSide" } } }, { - "name": "remaining_accounts_info", + "name": "_rounding", "type": { "defined": { - "name": "RemainingAccountsInfo" + "name": "Rounding" } } } ] + } + }, + { + "name": "DummyZcAccount", + "serialization": "bytemuck", + "repr": { + "kind": "c" }, - { - "name": "remove_liquidity_by_range2", - "discriminator": [ - 204, - 2, - 195, - 145, - 53, - 145, - 145, - 205 - ], - "accounts": [ + "type": { + "kind": "struct", + "fields": [ { - "name": "position", - "writable": true - }, + "name": "position_bin_data", + "type": { + "defined": { + "name": "PositionBinData" + } + } + } + ] + } + }, + { + "name": "DynamicFeeParameter", + "type": { + "kind": "struct", + "fields": [ { - "name": "lb_pair", - "writable": true + "name": "filter_period", + "docs": [ + "Filter period determine high frequency trading time window." + ], + "type": "u16" }, { - "name": "bin_array_bitmap_extension", - "writable": true, - "optional": true + "name": "decay_period", + "docs": [ + "Decay period determine when the volatile fee start decay / decrease." + ], + "type": "u16" }, { - "name": "user_token_x", - "writable": true + "name": "reduction_factor", + "docs": [ + "Reduction factor controls the volatile fee rate decrement rate." + ], + "type": "u16" }, { - "name": "user_token_y", - "writable": true + "name": "variable_fee_control", + "docs": [ + "Used to scale the variable fee component depending on the dynamic of the market" + ], + "type": "u32" }, { - "name": "reserve_x", - "writable": true - }, + "name": "max_volatility_accumulator", + "docs": [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ], + "type": "u32" + } + ] + } + }, + { + "name": "DynamicFeeParameterUpdate", + "type": { + "kind": "struct", + "fields": [ { - "name": "reserve_y", - "writable": true + "name": "lb_pair", + "type": "pubkey" }, { - "name": "token_x_mint" + "name": "filter_period", + "docs": [ + "Filter period determine high frequency trading time window." + ], + "type": "u16" }, { - "name": "token_y_mint" + "name": "decay_period", + "docs": [ + "Decay period determine when the volatile fee start decay / decrease." + ], + "type": "u16" }, { - "name": "sender", - "signer": true + "name": "reduction_factor", + "docs": [ + "Reduction factor controls the volatile fee rate decrement rate." + ], + "type": "u16" }, { - "name": "token_x_program" + "name": "variable_fee_control", + "docs": [ + "Used to scale the variable fee component depending on the dynamic of the market" + ], + "type": "u32" }, { - "name": "token_y_program" + "name": "max_volatility_accumulator", + "docs": [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ], + "type": "u32" + } + ] + } + }, + { + "name": "FeeInfo", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "fee_x_per_token_complete", + "type": "u128" }, { - "name": "memo_program" + "name": "fee_y_per_token_complete", + "type": "u128" }, { - "name": "event_authority" + "name": "fee_x_pending", + "type": "u64" }, { - "name": "program" + "name": "fee_y_pending", + "type": "u64" } - ], - "args": [ - { - "name": "from_bin_id", - "type": "i32" - }, + ] + } + }, + { + "name": "FeeParameterUpdate", + "type": { + "kind": "struct", + "fields": [ { - "name": "to_bin_id", - "type": "i32" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "bps_to_remove", + "name": "protocol_share", "type": "u16" }, { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" - } - } + "name": "base_factor", + "type": "u16" } ] - }, - { - "name": "swap2", - "discriminator": [ - 65, - 75, - 63, - 76, - 235, - 91, - 91, - 136 - ], - "accounts": [ + } + }, + { + "name": "FundReward", + "type": { + "kind": "struct", + "fields": [ { "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "optional": true + "type": "pubkey" }, { - "name": "reserve_x", - "writable": true + "name": "funder", + "type": "pubkey" }, { - "name": "reserve_y", - "writable": true + "name": "reward_index", + "type": "u64" }, { - "name": "user_token_in", - "writable": true - }, + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "GoToABin", + "type": { + "kind": "struct", + "fields": [ { - "name": "user_token_out", - "writable": true + "name": "lb_pair", + "type": "pubkey" }, { - "name": "token_x_mint" + "name": "from_bin_id", + "type": "i32" }, { - "name": "token_y_mint" - }, + "name": "to_bin_id", + "type": "i32" + } + ] + } + }, + { + "name": "IncreaseObservation", + "type": { + "kind": "struct", + "fields": [ { "name": "oracle", - "writable": true - }, - { - "name": "host_fee_in", - "writable": true, - "optional": true - }, - { - "name": "user", - "signer": true - }, - { - "name": "token_x_program" + "type": "pubkey" }, { - "name": "token_y_program" - }, + "name": "new_observation_length", + "type": "u64" + } + ] + } + }, + { + "name": "IncreasePositionLength", + "type": { + "kind": "struct", + "fields": [ { - "name": "memo_program" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "event_authority" + "name": "position", + "type": "pubkey" }, { - "name": "program" - } - ], - "args": [ - { - "name": "amount_in", - "type": "u64" + "name": "owner", + "type": "pubkey" }, { - "name": "min_amount_out", - "type": "u64" + "name": "length_to_add", + "type": "u16" }, { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" - } - } + "name": "side", + "type": "u8" } ] - }, - { - "name": "swap_exact_out2", - "discriminator": [ - 43, - 215, - 247, - 132, - 137, - 60, - 243, - 81 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, - { - "name": "bin_array_bitmap_extension", - "optional": true - }, + } + }, + { + "name": "InitPermissionPairIx", + "type": { + "kind": "struct", + "fields": [ { - "name": "reserve_x", - "writable": true + "name": "active_id", + "type": "i32" }, { - "name": "reserve_y", - "writable": true + "name": "bin_step", + "type": "u16" }, { - "name": "user_token_in", - "writable": true + "name": "base_factor", + "type": "u16" }, { - "name": "user_token_out", - "writable": true + "name": "base_fee_power_factor", + "type": "u8" }, { - "name": "token_x_mint" + "name": "activation_type", + "type": "u8" }, { - "name": "token_y_mint" - }, + "name": "protocol_share", + "type": "u16" + } + ] + } + }, + { + "name": "InitPresetParameters2Ix", + "type": { + "kind": "struct", + "fields": [ { - "name": "oracle", - "writable": true + "name": "index", + "type": "u16" }, { - "name": "host_fee_in", - "writable": true, - "optional": true + "name": "bin_step", + "docs": [ + "Bin step. Represent the price increment / decrement." + ], + "type": "u16" }, { - "name": "user", - "signer": true + "name": "base_factor", + "docs": [ + "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" + ], + "type": "u16" }, { - "name": "token_x_program" + "name": "filter_period", + "docs": [ + "Filter period determine high frequency trading time window." + ], + "type": "u16" }, { - "name": "token_y_program" + "name": "decay_period", + "docs": [ + "Decay period determine when the volatile fee start decay / decrease." + ], + "type": "u16" }, { - "name": "memo_program" + "name": "reduction_factor", + "docs": [ + "Reduction factor controls the volatile fee rate decrement rate." + ], + "type": "u16" }, { - "name": "event_authority" + "name": "variable_fee_control", + "docs": [ + "Used to scale the variable fee component depending on the dynamic of the market" + ], + "type": "u32" }, { - "name": "program" - } - ], - "args": [ - { - "name": "max_in_amount", - "type": "u64" + "name": "max_volatility_accumulator", + "docs": [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ], + "type": "u32" }, { - "name": "out_amount", - "type": "u64" + "name": "protocol_share", + "docs": [ + "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + ], + "type": "u16" }, { - "name": "remaining_accounts_info", - "type": { - "defined": { - "name": "RemainingAccountsInfo" - } - } + "name": "base_fee_power_factor", + "docs": [ + "Base fee power factor" + ], + "type": "u8" } ] - }, - { - "name": "swap_with_price_impact2", - "discriminator": [ - 74, - 98, - 192, - 214, - 177, - 51, - 75, - 51 - ], - "accounts": [ - { - "name": "lb_pair", - "writable": true - }, + } + }, + { + "name": "InitPresetParametersIx", + "type": { + "kind": "struct", + "fields": [ { - "name": "bin_array_bitmap_extension", - "optional": true + "name": "bin_step", + "docs": [ + "Bin step. Represent the price increment / decrement." + ], + "type": "u16" }, { - "name": "reserve_x", - "writable": true + "name": "base_factor", + "docs": [ + "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" + ], + "type": "u16" }, { - "name": "reserve_y", - "writable": true + "name": "filter_period", + "docs": [ + "Filter period determine high frequency trading time window." + ], + "type": "u16" }, { - "name": "user_token_in", - "writable": true + "name": "decay_period", + "docs": [ + "Decay period determine when the volatile fee start decay / decrease." + ], + "type": "u16" }, { - "name": "user_token_out", - "writable": true + "name": "reduction_factor", + "docs": [ + "Reduction factor controls the volatile fee rate decrement rate." + ], + "type": "u16" }, { - "name": "token_x_mint" + "name": "variable_fee_control", + "docs": [ + "Used to scale the variable fee component depending on the dynamic of the market" + ], + "type": "u32" }, { - "name": "token_y_mint" + "name": "max_volatility_accumulator", + "docs": [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ], + "type": "u32" }, { - "name": "oracle", - "writable": true - }, + "name": "protocol_share", + "docs": [ + "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + ], + "type": "u16" + } + ] + } + }, + { + "name": "InitializeLbPair2Params", + "type": { + "kind": "struct", + "fields": [ { - "name": "host_fee_in", - "writable": true, - "optional": true + "name": "active_id", + "docs": [ + "Pool price" + ], + "type": "i32" }, { - "name": "user", - "signer": true - }, + "name": "padding", + "docs": [ + "Padding, for future use" + ], + "type": { + "array": [ + "u8", + 96 + ] + } + } + ] + } + }, + { + "name": "InitializeReward", + "type": { + "kind": "struct", + "fields": [ { - "name": "token_x_program" + "name": "lb_pair", + "type": "pubkey" }, { - "name": "token_y_program" + "name": "reward_mint", + "type": "pubkey" }, { - "name": "memo_program" + "name": "funder", + "type": "pubkey" }, { - "name": "event_authority" + "name": "reward_index", + "type": "u64" }, { - "name": "program" - } - ], - "args": [ - { - "name": "amount_in", + "name": "reward_duration", "type": "u64" - }, + } + ] + } + }, + { + "name": "LbPair", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "active_id", + "name": "parameters", "type": { - "option": "i32" + "defined": { + "name": "StaticParameters" + } } }, { - "name": "max_price_impact_bps", - "type": "u16" - }, - { - "name": "remaining_accounts_info", + "name": "v_parameters", "type": { "defined": { - "name": "RemainingAccountsInfo" + "name": "VariableParameters" } } - } - ] - }, - { - "name": "close_position2", - "discriminator": [ - 174, - 90, - 35, - 115, - 186, - 40, - 147, - 226 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "sender", - "signer": true - }, - { - "name": "rent_receiver", - "writable": true }, { - "name": "event_authority" + "name": "bump_seed", + "type": { + "array": [ + "u8", + 1 + ] + } }, { - "name": "program" - } - ], - "args": [] - }, - { - "name": "update_fees_and_reward2", - "discriminator": [ - 32, - 142, - 184, - 154, - 103, - 65, - 184, - 88 - ], - "accounts": [ - { - "name": "position", - "writable": true + "name": "bin_step_seed", + "docs": [ + "Bin step signer seed" + ], + "type": { + "array": [ + "u8", + 2 + ] + } }, { - "name": "lb_pair", - "writable": true + "name": "pair_type", + "docs": [ + "Type of the pair" + ], + "type": "u8" }, { - "name": "owner", - "signer": true - } - ], - "args": [ - { - "name": "min_bin_id", + "name": "active_id", + "docs": [ + "Active bin id" + ], "type": "i32" }, { - "name": "max_bin_id", - "type": "i32" - } - ] - }, - { - "name": "close_position_if_empty", - "discriminator": [ - 59, - 124, - 212, - 118, - 91, - 152, - 110, - 157 - ], - "accounts": [ - { - "name": "position", - "writable": true + "name": "bin_step", + "docs": [ + "Bin step. Represent the price increment / decrement." + ], + "type": "u16" }, { - "name": "sender", - "signer": true + "name": "status", + "docs": [ + "Status of the pair. Check PairStatus enum." + ], + "type": "u8" }, { - "name": "rent_receiver", - "writable": true + "name": "require_base_factor_seed", + "docs": [ + "Require base factor seed" + ], + "type": "u8" }, { - "name": "event_authority" + "name": "base_factor_seed", + "docs": [ + "Base factor seed" + ], + "type": { + "array": [ + "u8", + 2 + ] + } }, { - "name": "program" - } - ], - "args": [] - } - ], - "accounts": [ - { - "name": "BinArrayBitmapExtension", - "discriminator": [ - 80, - 111, - 124, - 113, - 55, - 237, - 18, - 5 - ] - }, - { - "name": "ClaimFeeOperator", - "discriminator": [ - 166, - 48, - 134, - 86, - 34, - 200, - 188, - 150 - ] - }, - { - "name": "LbPair", - "discriminator": [ - 33, - 11, - 49, - 98, - 181, - 101, - 177, - 13 - ] - }, - { - "name": "Oracle", - "discriminator": [ - 139, - 194, - 131, - 179, - 140, - 179, - 229, - 244 - ] - }, - { - "name": "PresetParameter2", - "discriminator": [ - 171, - 236, - 148, - 115, - 162, - 113, - 222, - 174 - ] - }, - { - "name": "PresetParameter", - "discriminator": [ - 242, - 62, - 244, - 34, - 181, - 112, - 58, - 170 - ] - }, - { - "name": "TokenBadge", - "discriminator": [ - 116, - 219, - 204, - 229, - 249, - 116, - 255, - 150 - ] - } - ], - "events": [ - { - "name": "CompositionFee", - "discriminator": [ - 128, - 151, - 123, - 106, - 17, - 102, - 113, - 142 - ] - }, - { - "name": "AddLiquidity", - "discriminator": [ - 31, - 94, - 125, - 90, - 227, - 52, - 61, - 186 - ] - }, - { - "name": "RemoveLiquidity", - "discriminator": [ - 116, - 244, - 97, - 232, - 103, - 31, - 152, - 58 - ] - }, - { - "name": "Swap", - "discriminator": [ - 81, - 108, - 227, - 190, - 205, - 208, - 10, - 196 - ] - }, - { - "name": "ClaimReward", - "discriminator": [ - 148, - 116, - 134, - 204, - 22, - 171, - 85, - 95 - ] - }, - { - "name": "FundReward", - "discriminator": [ - 246, - 228, - 58, - 130, - 145, - 170, - 79, - 204 - ] - }, - { - "name": "InitializeReward", - "discriminator": [ - 211, - 153, - 88, - 62, - 149, - 60, - 177, - 70 - ] - }, - { - "name": "UpdateRewardDuration", - "discriminator": [ - 223, - 245, - 224, - 153, - 49, - 29, - 163, - 172 - ] - }, - { - "name": "UpdateRewardFunder", - "discriminator": [ - 224, - 178, - 174, - 74, - 252, - 165, - 85, - 180 - ] - }, - { - "name": "PositionClose", - "discriminator": [ - 255, - 196, - 16, - 107, - 28, - 202, - 53, - 128 - ] - }, - { - "name": "ClaimFee", - "discriminator": [ - 75, - 122, - 154, - 48, - 140, - 74, - 123, - 163 - ] - }, - { - "name": "LbPairCreate", - "discriminator": [ - 185, - 74, - 252, - 125, - 27, - 215, - 188, - 111 - ] - }, - { - "name": "PositionCreate", - "discriminator": [ - 144, - 142, - 252, - 84, - 157, - 53, - 37, - 121 - ] - }, - { - "name": "IncreasePositionLength", - "discriminator": [ - 157, - 239, - 42, - 204, - 30, - 56, - 223, - 46 - ] - }, - { - "name": "DecreasePositionLength", - "discriminator": [ - 52, - 118, - 235, - 85, - 172, - 169, - 15, - 128 - ] - }, - { - "name": "FeeParameterUpdate", - "discriminator": [ - 48, - 76, - 241, - 117, - 144, - 215, - 242, - 44 - ] - }, - { - "name": "DynamicFeeParameterUpdate", - "discriminator": [ - 88, - 88, - 178, - 135, - 194, - 146, - 91, - 243 - ] - }, - { - "name": "IncreaseObservation", - "discriminator": [ - 99, - 249, - 17, - 121, - 166, - 156, - 207, - 215 - ] - }, - { - "name": "WithdrawIneligibleReward", - "discriminator": [ - 231, - 189, - 65, - 149, - 102, - 215, - 154, - 244 - ] - }, - { - "name": "UpdatePositionOperator", - "discriminator": [ - 39, - 115, - 48, - 204, - 246, - 47, - 66, - 57 - ] - }, - { - "name": "UpdatePositionLockReleasePoint", - "discriminator": [ - 133, - 214, - 66, - 224, - 64, - 12, - 7, - 191 - ] - }, - { - "name": "GoToABin", - "discriminator": [ - 59, - 138, - 76, - 68, - 138, - 131, - 176, - 67 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "InvalidStartBinIndex", - "msg": "Invalid start bin index" - }, - { - "code": 6001, - "name": "InvalidBinId", - "msg": "Invalid bin id" - }, - { - "code": 6002, - "name": "InvalidInput", - "msg": "Invalid input data" - }, - { - "code": 6003, - "name": "ExceededAmountSlippageTolerance", - "msg": "Exceeded amount slippage tolerance" - }, - { - "code": 6004, - "name": "ExceededBinSlippageTolerance", - "msg": "Exceeded bin slippage tolerance" - }, - { - "code": 6005, - "name": "CompositionFactorFlawed", - "msg": "Composition factor flawed" - }, - { - "code": 6006, - "name": "NonPresetBinStep", - "msg": "Non preset bin step" - }, - { - "code": 6007, - "name": "ZeroLiquidity", - "msg": "Zero liquidity" - }, - { - "code": 6008, - "name": "InvalidPosition", - "msg": "Invalid position" - }, - { - "code": 6009, - "name": "BinArrayNotFound", - "msg": "Bin array not found" - }, - { - "code": 6010, - "name": "InvalidTokenMint", - "msg": "Invalid token mint" - }, - { - "code": 6011, - "name": "InvalidAccountForSingleDeposit", - "msg": "Invalid account for single deposit" - }, - { - "code": 6012, - "name": "PairInsufficientLiquidity", - "msg": "Pair insufficient liquidity" - }, - { - "code": 6013, - "name": "InvalidFeeOwner", - "msg": "Invalid fee owner" - }, - { - "code": 6014, - "name": "InvalidFeeWithdrawAmount", - "msg": "Invalid fee withdraw amount" - }, - { - "code": 6015, - "name": "InvalidAdmin", - "msg": "Invalid admin" - }, - { - "code": 6016, - "name": "IdenticalFeeOwner", - "msg": "Identical fee owner" - }, - { - "code": 6017, - "name": "InvalidBps", - "msg": "Invalid basis point" - }, - { - "code": 6018, - "name": "MathOverflow", - "msg": "Math operation overflow" - }, - { - "code": 6019, - "name": "TypeCastFailed", - "msg": "Type cast error" - }, - { - "code": 6020, - "name": "InvalidRewardIndex", - "msg": "Invalid reward index" - }, - { - "code": 6021, - "name": "InvalidRewardDuration", - "msg": "Invalid reward duration" - }, - { - "code": 6022, - "name": "RewardInitialized", - "msg": "Reward already initialized" - }, - { - "code": 6023, - "name": "RewardUninitialized", - "msg": "Reward not initialized" - }, - { - "code": 6024, - "name": "IdenticalFunder", - "msg": "Identical funder" - }, - { - "code": 6025, - "name": "RewardCampaignInProgress", - "msg": "Reward campaign in progress" - }, - { - "code": 6026, - "name": "IdenticalRewardDuration", - "msg": "Reward duration is the same" - }, - { - "code": 6027, - "name": "InvalidBinArray", - "msg": "Invalid bin array" - }, - { - "code": 6028, - "name": "NonContinuousBinArrays", - "msg": "Bin arrays must be continuous" - }, - { - "code": 6029, - "name": "InvalidRewardVault", - "msg": "Invalid reward vault" - }, - { - "code": 6030, - "name": "NonEmptyPosition", - "msg": "Position is not empty" - }, - { - "code": 6031, - "name": "UnauthorizedAccess", - "msg": "Unauthorized access" - }, - { - "code": 6032, - "name": "InvalidFeeParameter", - "msg": "Invalid fee parameter" - }, - { - "code": 6033, - "name": "MissingOracle", - "msg": "Missing oracle account" - }, - { - "code": 6034, - "name": "InsufficientSample", - "msg": "Insufficient observation sample" - }, - { - "code": 6035, - "name": "InvalidLookupTimestamp", - "msg": "Invalid lookup timestamp" - }, - { - "code": 6036, - "name": "BitmapExtensionAccountIsNotProvided", - "msg": "Bitmap extension account is not provided" - }, - { - "code": 6037, - "name": "CannotFindNonZeroLiquidityBinArrayId", - "msg": "Cannot find non-zero liquidity binArrayId" - }, - { - "code": 6038, - "name": "BinIdOutOfBound", - "msg": "Bin id out of bound" - }, - { - "code": 6039, - "name": "InsufficientOutAmount", - "msg": "Insufficient amount in for minimum out" - }, - { - "code": 6040, - "name": "InvalidPositionWidth", - "msg": "Invalid position width" - }, - { - "code": 6041, - "name": "ExcessiveFeeUpdate", - "msg": "Excessive fee update" - }, - { - "code": 6042, - "name": "PoolDisabled", - "msg": "Pool disabled" - }, - { - "code": 6043, - "name": "InvalidPoolType", - "msg": "Invalid pool type" - }, - { - "code": 6044, - "name": "ExceedMaxWhitelist", - "msg": "Whitelist for wallet is full" - }, - { - "code": 6045, - "name": "InvalidIndex", - "msg": "Invalid index" - }, - { - "code": 6046, - "name": "RewardNotEnded", - "msg": "Reward not ended" - }, - { - "code": 6047, - "name": "MustWithdrawnIneligibleReward", - "msg": "Must withdraw ineligible reward" - }, - { - "code": 6048, - "name": "UnauthorizedAddress", - "msg": "Unauthorized address" - }, - { - "code": 6049, - "name": "OperatorsAreTheSame", - "msg": "Cannot update because operators are the same" - }, - { - "code": 6050, - "name": "WithdrawToWrongTokenAccount", - "msg": "Withdraw to wrong token account" - }, - { - "code": 6051, - "name": "WrongRentReceiver", - "msg": "Wrong rent receiver" - }, - { - "code": 6052, - "name": "AlreadyPassActivationPoint", - "msg": "Already activated" - }, - { - "code": 6053, - "name": "ExceedMaxSwappedAmount", - "msg": "Swapped amount is exceeded max swapped amount" - }, - { - "code": 6054, - "name": "InvalidStrategyParameters", - "msg": "Invalid strategy parameters" - }, - { - "code": 6055, - "name": "LiquidityLocked", - "msg": "Liquidity locked" - }, - { - "code": 6056, - "name": "BinRangeIsNotEmpty", - "msg": "Bin range is not empty" - }, - { - "code": 6057, - "name": "NotExactAmountOut", - "msg": "Amount out is not matched with exact amount out" - }, - { - "code": 6058, - "name": "InvalidActivationType", - "msg": "Invalid activation type" - }, - { - "code": 6059, - "name": "InvalidActivationDuration", - "msg": "Invalid activation duration" - }, - { - "code": 6060, - "name": "MissingTokenAmountAsTokenLaunchProof", - "msg": "Missing token amount as token launch owner proof" - }, - { - "code": 6061, - "name": "InvalidQuoteToken", - "msg": "Quote token must be SOL or USDC" - }, - { - "code": 6062, - "name": "InvalidBinStep", - "msg": "Invalid bin step" - }, - { - "code": 6063, - "name": "InvalidBaseFee", - "msg": "Invalid base fee" - }, - { - "code": 6064, - "name": "InvalidPreActivationDuration", - "msg": "Invalid pre-activation duration" - }, - { - "code": 6065, - "name": "AlreadyPassPreActivationSwapPoint", - "msg": "Already pass pre-activation swap point" - }, - { - "code": 6066, - "name": "InvalidStatus", - "msg": "Invalid status" - }, - { - "code": 6067, - "name": "ExceededMaxOracleLength", - "msg": "Exceed max oracle length" - }, - { - "code": 6068, - "name": "InvalidMinimumLiquidity", - "msg": "Invalid minimum liquidity" - }, - { - "code": 6069, - "name": "NotSupportMint", - "msg": "Not support token_2022 mint extension" - }, - { - "code": 6070, - "name": "UnsupportedMintExtension", - "msg": "Unsupported mint extension" - }, - { - "code": 6071, - "name": "UnsupportNativeMintToken2022", - "msg": "Unsupported native mint token2022" - }, - { - "code": 6072, - "name": "UnmatchTokenMint", - "msg": "Unmatch token mint" - }, - { - "code": 6073, - "name": "UnsupportedTokenMint", - "msg": "Unsupported token mint" - }, - { - "code": 6074, - "name": "InsufficientRemainingAccounts", - "msg": "Insufficient remaining accounts" - }, - { - "code": 6075, - "name": "InvalidRemainingAccountSlice", - "msg": "Invalid remaining account slice" - }, - { - "code": 6076, - "name": "DuplicatedRemainingAccountTypes", - "msg": "Duplicated remaining account types" - }, - { - "code": 6077, - "name": "MissingRemainingAccountForTransferHook", - "msg": "Missing remaining account for transfer hook" - }, - { - "code": 6078, - "name": "NoTransferHookProgram", - "msg": "Remaining account was passed for transfer hook but there's no hook program" - }, - { - "code": 6079, - "name": "ZeroFundedAmount", - "msg": "Zero funded amount" - }, - { - "code": 6080, - "name": "InvalidSide", - "msg": "Invalid side" - }, - { - "code": 6081, - "name": "InvalidResizeLength", - "msg": "Invalid resize length" - }, - { - "code": 6082, - "name": "NotSupportAtTheMoment", - "msg": "Not support at the moment" - } - ], - "types": [ - { - "name": "InitPresetParameters2Ix", - "type": { - "kind": "struct", - "fields": [ - { - "name": "index", - "type": "u16" - }, - { - "name": "bin_step", - "docs": [ - "Bin step. Represent the price increment / decrement." - ], - "type": "u16" - }, - { - "name": "base_factor", - "docs": [ - "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" - ], - "type": "u16" - }, - { - "name": "filter_period", - "docs": [ - "Filter period determine high frequency trading time window." - ], - "type": "u16" - }, - { - "name": "decay_period", - "docs": [ - "Decay period determine when the volatile fee start decay / decrease." - ], - "type": "u16" - }, - { - "name": "reduction_factor", - "docs": [ - "Reduction factor controls the volatile fee rate decrement rate." - ], - "type": "u16" - }, - { - "name": "variable_fee_control", - "docs": [ - "Used to scale the variable fee component depending on the dynamic of the market" - ], - "type": "u32" - }, - { - "name": "max_volatility_accumulator", - "docs": [ - "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." - ], - "type": "u32" - }, - { - "name": "protocol_share", - "docs": [ - "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" - }, - { - "name": "base_fee_power_factor", - "docs": [ - "Base fee power factor" - ], - "type": "u8" - } - ] - } - }, - { - "name": "InitPresetParametersIx", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bin_step", - "docs": [ - "Bin step. Represent the price increment / decrement." - ], - "type": "u16" - }, - { - "name": "base_factor", - "docs": [ - "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" - ], - "type": "u16" - }, - { - "name": "filter_period", - "docs": [ - "Filter period determine high frequency trading time window." - ], - "type": "u16" - }, - { - "name": "decay_period", - "docs": [ - "Decay period determine when the volatile fee start decay / decrease." - ], - "type": "u16" - }, - { - "name": "reduction_factor", - "docs": [ - "Reduction factor controls the volatile fee rate decrement rate." - ], - "type": "u16" - }, - { - "name": "variable_fee_control", - "docs": [ - "Used to scale the variable fee component depending on the dynamic of the market" - ], - "type": "u32" - }, - { - "name": "max_volatility_accumulator", - "docs": [ - "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." - ], - "type": "u32" - }, - { - "name": "protocol_share", - "docs": [ - "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" - } - ] - } - }, - { - "name": "BaseFeeParameter", - "type": { - "kind": "struct", - "fields": [ - { - "name": "protocol_share", - "docs": [ - "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" - }, - { - "name": "base_factor", - "docs": [ - "Base factor for base fee rate" - ], - "type": "u16" - }, - { - "name": "base_fee_power_factor", - "docs": [ - "Base fee power factor" - ], - "type": "u8" - } - ] - } - }, - { - "name": "DynamicFeeParameter", - "type": { - "kind": "struct", - "fields": [ - { - "name": "filter_period", - "docs": [ - "Filter period determine high frequency trading time window." - ], - "type": "u16" - }, - { - "name": "decay_period", - "docs": [ - "Decay period determine when the volatile fee start decay / decrease." - ], - "type": "u16" - }, - { - "name": "reduction_factor", - "docs": [ - "Reduction factor controls the volatile fee rate decrement rate." - ], - "type": "u16" - }, - { - "name": "variable_fee_control", - "docs": [ - "Used to scale the variable fee component depending on the dynamic of the market" - ], - "type": "u32" - }, - { - "name": "max_volatility_accumulator", - "docs": [ - "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." - ], - "type": "u32" - } - ] - } - }, - { - "name": "LiquidityParameterByStrategyOneSide", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "docs": [ - "Amount of X token or Y token to deposit" - ], - "type": "u64" - }, - { - "name": "active_id", - "docs": [ - "Active bin that integrator observe off-chain" - ], - "type": "i32" - }, - { - "name": "max_active_bin_slippage", - "docs": [ - "max active bin slippage allowed" - ], - "type": "i32" - }, - { - "name": "strategy_parameters", - "docs": [ - "strategy parameters" - ], - "type": { - "defined": { - "name": "StrategyParameters" - } - } - } - ] - } - }, - { - "name": "LiquidityParameterByStrategy", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount_x", - "docs": [ - "Amount of X token to deposit" - ], - "type": "u64" - }, - { - "name": "amount_y", - "docs": [ - "Amount of Y token to deposit" - ], - "type": "u64" - }, - { - "name": "active_id", - "docs": [ - "Active bin that integrator observe off-chain" - ], - "type": "i32" - }, - { - "name": "max_active_bin_slippage", - "docs": [ - "max active bin slippage allowed" - ], - "type": "i32" - }, - { - "name": "strategy_parameters", - "docs": [ - "strategy parameters" - ], - "type": { - "defined": { - "name": "StrategyParameters" - } + "name": "activation_type", + "docs": [ + "Activation type" + ], + "type": "u8" + }, + { + "name": "creator_pool_on_off_control", + "docs": [ + "Allow pool creator to enable/disable pool with restricted validation. Only applicable for customizable permissionless pair type." + ], + "type": "u8" + }, + { + "name": "token_x_mint", + "docs": [ + "Token X mint" + ], + "type": "pubkey" + }, + { + "name": "token_y_mint", + "docs": [ + "Token Y mint" + ], + "type": "pubkey" + }, + { + "name": "reserve_x", + "docs": [ + "LB token X vault" + ], + "type": "pubkey" + }, + { + "name": "reserve_y", + "docs": [ + "LB token Y vault" + ], + "type": "pubkey" + }, + { + "name": "protocol_fee", + "docs": [ + "Uncollected protocol fee" + ], + "type": { + "defined": { + "name": "ProtocolFee" } } - ] - } - }, - { - "name": "StrategyParameters", - "type": { - "kind": "struct", - "fields": [ - { - "name": "min_bin_id", - "docs": [ - "min bin id" - ], - "type": "i32" - }, - { - "name": "max_bin_id", - "docs": [ - "max bin id" - ], - "type": "i32" - }, - { - "name": "strategy_type", - "docs": [ - "strategy type" - ], - "type": { - "defined": { - "name": "StrategyType" - } - } - }, - { - "name": "parameteres", - "docs": [ - "parameters" - ], - "type": { - "array": [ - "u8", - 64 - ] - } + }, + { + "name": "_padding_1", + "docs": [ + "_padding_1, previous Fee owner, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + ], + "type": { + "array": [ + "u8", + 32 + ] } - ] - } - }, - { - "name": "LiquidityOneSideParameter", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "docs": [ - "Amount of X token or Y token to deposit" - ], - "type": "u64" - }, - { - "name": "active_id", - "docs": [ - "Active bin that integrator observe off-chain" - ], - "type": "i32" - }, - { - "name": "max_active_bin_slippage", - "docs": [ - "max active bin slippage allowed" - ], - "type": "i32" - }, - { - "name": "bin_liquidity_dist", - "docs": [ - "Liquidity distribution to each bins" - ], - "type": { - "vec": { + }, + { + "name": "reward_infos", + "docs": [ + "Farming reward information" + ], + "type": { + "array": [ + { "defined": { - "name": "BinLiquidityDistributionByWeight" + "name": "RewardInfo" } - } - } + }, + 2 + ] } - ] - } - }, - { - "name": "BinLiquidityDistributionByWeight", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bin_id", - "docs": [ - "Define the bin ID wish to deposit to." - ], - "type": "i32" - }, - { - "name": "weight", - "docs": [ - "weight of liquidity distributed for this bin id" - ], - "type": "u16" + }, + { + "name": "oracle", + "docs": [ + "Oracle pubkey" + ], + "type": "pubkey" + }, + { + "name": "bin_array_bitmap", + "docs": [ + "Packed initialized bin array state" + ], + "type": { + "array": [ + "u64", + 16 + ] } - ] - } - }, - { - "name": "LiquidityParameterByWeight", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount_x", - "docs": [ - "Amount of X token to deposit" - ], - "type": "u64" - }, - { - "name": "amount_y", - "docs": [ - "Amount of Y token to deposit" - ], - "type": "u64" - }, - { - "name": "active_id", - "docs": [ - "Active bin that integrator observe off-chain" - ], - "type": "i32" - }, - { - "name": "max_active_bin_slippage", - "docs": [ - "max active bin slippage allowed" - ], - "type": "i32" - }, - { - "name": "bin_liquidity_dist", - "docs": [ - "Liquidity distribution to each bins" - ], - "type": { - "vec": { - "defined": { - "name": "BinLiquidityDistributionByWeight" - } + }, + { + "name": "last_updated_at", + "docs": [ + "Last time the pool fee parameter was updated" + ], + "type": "i64" + }, + { + "name": "_padding_2", + "docs": [ + "_padding_2, previous whitelisted_wallet, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "pre_activation_swap_address", + "docs": [ + "Address allowed to swap when the current point is greater than or equal to the pre-activation point. The pre-activation point is calculated as `activation_point - pre_activation_duration`." + ], + "type": "pubkey" + }, + { + "name": "base_key", + "docs": [ + "Base keypair. Only required for permission pair" + ], + "type": "pubkey" + }, + { + "name": "activation_point", + "docs": [ + "Time point to enable the pair. Only applicable for permission pair." + ], + "type": "u64" + }, + { + "name": "pre_activation_duration", + "docs": [ + "Duration before activation activation_point. Used to calculate pre-activation time point for pre_activation_swap_address" + ], + "type": "u64" + }, + { + "name": "_padding_3", + "docs": [ + "_padding 3 is reclaimed free space from swap_cap_deactivate_point and swap_cap_amount before, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + ], + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "_padding_4", + "docs": [ + "_padding_4, previous lock_duration, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + ], + "type": "u64" + }, + { + "name": "creator", + "docs": [ + "Pool creator" + ], + "type": "pubkey" + }, + { + "name": "token_mint_x_program_flag", + "docs": [ + "token_mint_x_program_flag" + ], + "type": "u8" + }, + { + "name": "token_mint_y_program_flag", + "docs": [ + "token_mint_y_program_flag" + ], + "type": "u8" + }, + { + "name": "_reserved", + "docs": [ + "Reserved space for future use" + ], + "type": { + "array": [ + "u8", + 22 + ] + } + } + ] + } + }, + { + "name": "LbPairCreate", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lb_pair", + "type": "pubkey" + }, + { + "name": "bin_step", + "type": "u16" + }, + { + "name": "token_x", + "type": "pubkey" + }, + { + "name": "token_y", + "type": "pubkey" + } + ] + } + }, + { + "name": "LiquidityOneSideParameter", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "docs": [ + "Amount of X token or Y token to deposit" + ], + "type": "u64" + }, + { + "name": "active_id", + "docs": [ + "Active bin that integrator observe off-chain" + ], + "type": "i32" + }, + { + "name": "max_active_bin_slippage", + "docs": [ + "max active bin slippage allowed" + ], + "type": "i32" + }, + { + "name": "bin_liquidity_dist", + "docs": [ + "Liquidity distribution to each bins" + ], + "type": { + "vec": { + "defined": { + "name": "BinLiquidityDistributionByWeight" } } } - ] - } - }, - { - "name": "AddLiquiditySingleSidePreciseParameter", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bins", - "type": { - "vec": { - "defined": { - "name": "CompressedBinDepositAmount" - } + } + ] + } + }, + { + "name": "LiquidityParameter", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount_x", + "docs": [ + "Amount of X token to deposit" + ], + "type": "u64" + }, + { + "name": "amount_y", + "docs": [ + "Amount of Y token to deposit" + ], + "type": "u64" + }, + { + "name": "bin_liquidity_dist", + "docs": [ + "Liquidity distribution to each bins" + ], + "type": { + "vec": { + "defined": { + "name": "BinLiquidityDistribution" } } - }, - { - "name": "decompress_multiplier", - "type": "u64" - } - ] - } - }, - { - "name": "CompressedBinDepositAmount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bin_id", - "type": "i32" - }, - { - "name": "amount", - "type": "u32" - } - ] - } - }, - { - "name": "BinLiquidityDistribution", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bin_id", - "docs": [ - "Define the bin ID wish to deposit to." - ], - "type": "i32" - }, - { - "name": "distribution_x", - "docs": [ - "DistributionX (or distributionY) is the percentages of amountX (or amountY) you want to add to each bin." - ], - "type": "u16" - }, - { - "name": "distribution_y", - "docs": [ - "DistributionX (or distributionY) is the percentages of amountX (or amountY) you want to add to each bin." - ], - "type": "u16" } - ] - } - }, - { - "name": "LiquidityParameter", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount_x", - "docs": [ - "Amount of X token to deposit" - ], - "type": "u64" - }, - { - "name": "amount_y", - "docs": [ - "Amount of Y token to deposit" - ], - "type": "u64" - }, - { - "name": "bin_liquidity_dist", - "docs": [ - "Liquidity distribution to each bins" - ], - "type": { - "vec": { - "defined": { - "name": "BinLiquidityDistribution" - } - } + } + ] + } + }, + { + "name": "LiquidityParameterByStrategy", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount_x", + "docs": [ + "Amount of X token to deposit" + ], + "type": "u64" + }, + { + "name": "amount_y", + "docs": [ + "Amount of Y token to deposit" + ], + "type": "u64" + }, + { + "name": "active_id", + "docs": [ + "Active bin that integrator observe off-chain" + ], + "type": "i32" + }, + { + "name": "max_active_bin_slippage", + "docs": [ + "max active bin slippage allowed" + ], + "type": "i32" + }, + { + "name": "strategy_parameters", + "docs": [ + "strategy parameters" + ], + "type": { + "defined": { + "name": "StrategyParameters" } } - ] - } - }, - { - "name": "CustomizableParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "active_id", - "docs": [ - "Pool price" - ], - "type": "i32" - }, - { - "name": "bin_step", - "docs": [ - "Bin step" - ], - "type": "u16" - }, - { - "name": "base_factor", - "docs": [ - "Base factor" - ], - "type": "u16" - }, - { - "name": "activation_type", - "docs": [ - "Activation type. 0 = Slot, 1 = Time. Check ActivationType enum" - ], - "type": "u8" - }, - { - "name": "has_alpha_vault", - "docs": [ - "Whether the pool has an alpha vault" - ], - "type": "bool" - }, - { - "name": "activation_point", - "docs": [ - "Decide when does the pool start trade. None = Now" - ], - "type": { - "option": "u64" - } - }, - { - "name": "creator_pool_on_off_control", - "docs": [ - "Pool creator have permission to enable/disable pool with restricted program validation. Only applicable for customizable permissionless pool." - ], - "type": "bool" - }, - { - "name": "base_fee_power_factor", - "docs": [ - "Base fee power factor" - ], - "type": "u8" - }, - { - "name": "padding", - "docs": [ - "Padding, for future use" - ], - "type": { - "array": [ - "u8", - 62 - ] + } + ] + } + }, + { + "name": "LiquidityParameterByStrategyOneSide", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "docs": [ + "Amount of X token or Y token to deposit" + ], + "type": "u64" + }, + { + "name": "active_id", + "docs": [ + "Active bin that integrator observe off-chain" + ], + "type": "i32" + }, + { + "name": "max_active_bin_slippage", + "docs": [ + "max active bin slippage allowed" + ], + "type": "i32" + }, + { + "name": "strategy_parameters", + "docs": [ + "strategy parameters" + ], + "type": { + "defined": { + "name": "StrategyParameters" } } - ] - } - }, - { - "name": "InitPermissionPairIx", - "type": { - "kind": "struct", - "fields": [ - { - "name": "active_id", - "type": "i32" - }, - { - "name": "bin_step", - "type": "u16" - }, - { - "name": "base_factor", - "type": "u16" - }, - { - "name": "base_fee_power_factor", - "type": "u8" - }, - { - "name": "activation_type", - "type": "u8" - }, - { - "name": "protocol_share", - "type": "u16" - } - ] - } - }, - { - "name": "AddLiquiditySingleSidePreciseParameter2", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bins", - "type": { - "vec": { - "defined": { - "name": "CompressedBinDepositAmount" - } + } + ] + } + }, + { + "name": "LiquidityParameterByWeight", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount_x", + "docs": [ + "Amount of X token to deposit" + ], + "type": "u64" + }, + { + "name": "amount_y", + "docs": [ + "Amount of Y token to deposit" + ], + "type": "u64" + }, + { + "name": "active_id", + "docs": [ + "Active bin that integrator observe off-chain" + ], + "type": "i32" + }, + { + "name": "max_active_bin_slippage", + "docs": [ + "max active bin slippage allowed" + ], + "type": "i32" + }, + { + "name": "bin_liquidity_dist", + "docs": [ + "Liquidity distribution to each bins" + ], + "type": { + "vec": { + "defined": { + "name": "BinLiquidityDistributionByWeight" } } - }, - { - "name": "decompress_multiplier", - "type": "u64" - }, - { - "name": "max_amount", - "type": "u64" - } - ] - } - }, - { - "name": "CompressedBinDepositAmount2", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bin_id", - "type": "i32" - }, - { - "name": "amount", - "type": "u32" - } - ] - } - }, - { - "name": "InitializeLbPair2Params", - "type": { - "kind": "struct", - "fields": [ - { - "name": "active_id", - "docs": [ - "Pool price" - ], - "type": "i32" - }, - { - "name": "padding", - "docs": [ - "Padding, for future use" - ], - "type": { - "array": [ - "u8", - 96 - ] - } - } - ] - } - }, - { - "name": "BinLiquidityReduction", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bin_id", - "type": "i32" - }, - { - "name": "bps_to_remove", - "type": "u16" - } - ] - } - }, - { - "name": "Bin", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount_x", - "docs": [ - "Amount of token X in the bin. This already excluded protocol fees." - ], - "type": "u64" - }, - { - "name": "amount_y", - "docs": [ - "Amount of token Y in the bin. This already excluded protocol fees." - ], - "type": "u64" - }, - { - "name": "price", - "docs": [ - "Bin price" - ], - "type": "u128" - }, - { - "name": "liquidity_supply", - "docs": [ - "Liquidities of the bin. This is the same as LP mint supply. q-number" - ], - "type": "u128" - }, - { - "name": "reward_per_token_stored", - "docs": [ - "reward_a_per_token_stored" - ], - "type": { - "array": [ - "u128", - 2 - ] - } - }, - { - "name": "fee_amount_x_per_token_stored", - "docs": [ - "Swap fee amount of token X per liquidity deposited." - ], - "type": "u128" - }, - { - "name": "fee_amount_y_per_token_stored", - "docs": [ - "Swap fee amount of token Y per liquidity deposited." - ], - "type": "u128" - }, - { - "name": "amount_x_in", - "docs": [ - "Total token X swap into the bin. Only used for tracking purpose." - ], - "type": "u128" - }, - { - "name": "amount_y_in", - "docs": [ - "Total token Y swap into he bin. Only used for tracking purpose." - ], - "type": "u128" - } - ] - } - }, - { - "name": "ProtocolFee", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount_x", - "type": "u64" - }, - { - "name": "amount_y", - "type": "u64" - } - ] - } - }, - { - "name": "RewardInfo", - "docs": [ - "Stores the state relevant for tracking liquidity mining rewards" - ], - "type": { - "kind": "struct", - "fields": [ - { - "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": [ - "TODO check whether we need to store it in pool" - ], - "type": "u64" - }, - { - "name": "reward_duration_end", - "docs": [ - "TODO check whether we need to store it in pool" - ], - "type": "u64" - }, - { - "name": "reward_rate", - "docs": [ - "TODO check whether we need to store it in pool" - ], - "type": "u128" - }, - { - "name": "last_update_time", - "docs": [ - "The last time reward states were updated." - ], - "type": "u64" - }, - { - "name": "cumulative_seconds_with_empty_liquidity_reward", - "docs": [ - "Accumulated seconds where when farm distribute rewards, but the bin is empty. The reward will be accumulated for next reward time window." - ], - "type": "u64" - } - ] - } - }, - { - "name": "Observation", - "type": { - "kind": "struct", - "fields": [ - { - "name": "cumulative_active_bin_id", - "docs": [ - "Cumulative active bin ID" - ], - "type": "i128" - }, - { - "name": "created_at", - "docs": [ - "Observation sample created timestamp" - ], - "type": "i64" - }, - { - "name": "last_updated_at", - "docs": [ - "Observation sample last updated timestamp" - ], - "type": "i64" } - ] - } + } + ] + } + }, + { + "name": "Oracle", + "serialization": "bytemuck", + "repr": { + "kind": "c" }, - { - "name": "StaticParameters", - "docs": [ - "Parameter that set by the protocol" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "base_factor", - "docs": [ - "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" - ], - "type": "u16" - }, - { - "name": "filter_period", - "docs": [ - "Filter period determine high frequency trading time window." - ], - "type": "u16" - }, - { - "name": "decay_period", - "docs": [ - "Decay period determine when the volatile fee start decay / decrease." - ], - "type": "u16" - }, - { - "name": "reduction_factor", - "docs": [ - "Reduction factor controls the volatile fee rate decrement rate." - ], - "type": "u16" - }, - { - "name": "variable_fee_control", - "docs": [ - "Used to scale the variable fee component depending on the dynamic of the market" - ], - "type": "u32" - }, - { - "name": "max_volatility_accumulator", - "docs": [ - "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." - ], - "type": "u32" - }, - { - "name": "min_bin_id", - "docs": [ - "Min bin id supported by the pool based on the configured bin step." - ], - "type": "i32" - }, - { - "name": "max_bin_id", - "docs": [ - "Max bin id supported by the pool based on the configured bin step." - ], - "type": "i32" - }, - { - "name": "protocol_share", - "docs": [ - "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" - }, - { - "name": "base_fee_power_factor", - "docs": [ - "Base fee power factor" - ], - "type": "u8" - }, - { - "name": "padding", - "docs": [ - "Padding for bytemuck safe alignment" - ], - "type": { - "array": [ - "u8", - 5 - ] - } - } - ] - } + "type": { + "kind": "struct", + "fields": [ + { + "name": "idx", + "docs": [ + "Index of latest observation" + ], + "type": "u64" + }, + { + "name": "active_size", + "docs": [ + "Size of active sample. Active sample is initialized observation." + ], + "type": "u64" + }, + { + "name": "length", + "docs": [ + "Number of observations" + ], + "type": "u64" + } + ] + } + }, + { + "name": "PairStatus", + "docs": [ + "Pair status. 0 = Enabled, 1 = Disabled. Putting 0 as enabled for backward compatibility." + ], + "repr": { + "kind": "rust" }, - { - "name": "VariableParameters", - "docs": [ - "Parameters that changes based on dynamic of the market" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "volatility_accumulator", - "docs": [ - "Volatility accumulator measure the number of bin crossed since reference bin ID. Normally (without filter period taken into consideration), reference bin ID is the active bin of last swap.", - "It affects the variable fee rate" - ], - "type": "u32" - }, - { - "name": "volatility_reference", - "docs": [ - "Volatility reference is decayed volatility accumulator. It is always <= volatility_accumulator" - ], - "type": "u32" - }, - { - "name": "index_reference", - "docs": [ - "Active bin id of last swap." - ], - "type": "i32" - }, - { - "name": "padding", - "docs": [ - "Padding for bytemuck safe alignment" - ], - "type": { - "array": [ - "u8", - 4 - ] - } - }, - { - "name": "last_update_timestamp", - "docs": [ - "Last timestamp the variable parameters was updated" - ], - "type": "i64" - }, - { - "name": "padding1", - "docs": [ - "Padding for bytemuck safe alignment" - ], - "type": { - "array": [ - "u8", - 8 - ] - } - } - ] - } + "type": { + "kind": "enum", + "variants": [ + { + "name": "Enabled" + }, + { + "name": "Disabled" + } + ] + } + }, + { + "name": "PairType", + "docs": [ + "Type of the Pair. 0 = Permissionless, 1 = Permission, 2 = CustomizablePermissionless. Putting 0 as permissionless for backward compatibility." + ], + "repr": { + "kind": "rust" }, - { - "name": "FeeInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "fee_x_per_token_complete", - "type": "u128" - }, - { - "name": "fee_y_per_token_complete", - "type": "u128" - }, - { - "name": "fee_x_pending", - "type": "u64" - }, - { - "name": "fee_y_pending", - "type": "u64" - } - ] - } + "type": { + "kind": "enum", + "variants": [ + { + "name": "Permissionless" + }, + { + "name": "Permission" + }, + { + "name": "CustomizablePermissionless" + }, + { + "name": "PermissionlessV2" + } + ] + } + }, + { + "name": "Position", + "serialization": "bytemuck", + "repr": { + "kind": "c" }, - { - "name": "UserRewardInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "reward_per_token_completes", - "type": { - "array": [ - "u128", - 2 - ] - } - }, - { - "name": "reward_pendings", - "type": { - "array": [ - "u64", - 2 - ] - } + "type": { + "kind": "struct", + "fields": [ + { + "name": "lb_pair", + "docs": [ + "The LB pair of this position" + ], + "type": "pubkey" + }, + { + "name": "owner", + "docs": [ + "Owner of the position. Client rely on this to to fetch their positions." + ], + "type": "pubkey" + }, + { + "name": "liquidity_shares", + "docs": [ + "Liquidity shares of this position in bins (lower_bin_id <-> upper_bin_id). This is the same as LP concept." + ], + "type": { + "array": [ + "u64", + 70 + ] } - ] - } - }, - { - "name": "RemainingAccountsSlice", - "type": { - "kind": "struct", - "fields": [ - { - "name": "accounts_type", - "type": { - "defined": { - "name": "AccountsType" - } - } - }, - { - "name": "length", - "type": "u8" + }, + { + "name": "reward_infos", + "docs": [ + "Farming reward information" + ], + "type": { + "array": [ + { + "defined": { + "name": "UserRewardInfo" + } + }, + 70 + ] } - ] - } - }, - { - "name": "RemainingAccountsInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "slices", - "type": { - "vec": { + }, + { + "name": "fee_infos", + "docs": [ + "Swap fee to claim information" + ], + "type": { + "array": [ + { "defined": { - "name": "RemainingAccountsSlice" + "name": "FeeInfo" } - } - } + }, + 70 + ] } - ] - } - }, - { - "name": "StrategyType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "SpotOneSide" - }, - { - "name": "CurveOneSide" - }, - { - "name": "BidAskOneSide" - }, - { - "name": "SpotBalanced" - }, - { - "name": "CurveBalanced" - }, - { - "name": "BidAskBalanced" - }, - { - "name": "SpotImBalanced" - }, - { - "name": "CurveImBalanced" - }, - { - "name": "BidAskImBalanced" + }, + { + "name": "lower_bin_id", + "docs": [ + "Lower bin ID" + ], + "type": "i32" + }, + { + "name": "upper_bin_id", + "docs": [ + "Upper bin ID" + ], + "type": "i32" + }, + { + "name": "last_updated_at", + "docs": [ + "Last updated timestamp" + ], + "type": "i64" + }, + { + "name": "total_claimed_fee_x_amount", + "docs": [ + "Total claimed token fee X" + ], + "type": "u64" + }, + { + "name": "total_claimed_fee_y_amount", + "docs": [ + "Total claimed token fee Y" + ], + "type": "u64" + }, + { + "name": "total_claimed_rewards", + "docs": [ + "Total claimed rewards" + ], + "type": { + "array": [ + "u64", + 2 + ] } - ] - } - }, - { - "name": "Rounding", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Up" - }, - { - "name": "Down" + }, + { + "name": "_reserved", + "docs": [ + "Reserved space for future use" + ], + "type": { + "array": [ + "u8", + 160 + ] } - ] - } + } + ] + } + }, + { + "name": "PositionBinData", + "serialization": "bytemuck", + "repr": { + "kind": "c" }, - { - "name": "ActivationType", - "docs": [ - "Type of the activation" - ], - "type": { - "kind": "enum", - "variants": [ - { - "name": "Slot" - }, - { - "name": "Timestamp" + "type": { + "kind": "struct", + "fields": [ + { + "name": "liquidity_share", + "type": "u128" + }, + { + "name": "reward_info", + "type": { + "defined": { + "name": "UserRewardInfo" + } } - ] - } - }, - { - "name": "LayoutVersion", - "docs": [ - "Layout version" - ], - "type": { - "kind": "enum", - "variants": [ - { - "name": "V0" - }, - { - "name": "V1" + }, + { + "name": "fee_info", + "type": { + "defined": { + "name": "FeeInfo" + } } - ] - } + } + ] + } + }, + { + "name": "PositionClose", + "type": { + "kind": "struct", + "fields": [ + { + "name": "position", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "PositionCreate", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lb_pair", + "type": "pubkey" + }, + { + "name": "position", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "PositionV2", + "serialization": "bytemuck", + "repr": { + "kind": "c" }, - { - "name": "PairType", - "docs": [ - "Type of the Pair. 0 = Permissionless, 1 = Permission, 2 = CustomizablePermissionless. Putting 0 as permissionless for backward compatibility." - ], - "type": { - "kind": "enum", - "variants": [ - { - "name": "Permissionless" - }, - { - "name": "Permission" - }, - { - "name": "CustomizablePermissionless" - }, - { - "name": "PermissionlessV2" + "type": { + "kind": "struct", + "fields": [ + { + "name": "lb_pair", + "docs": [ + "The LB pair of this position" + ], + "type": "pubkey" + }, + { + "name": "owner", + "docs": [ + "Owner of the position. Client rely on this to to fetch their positions." + ], + "type": "pubkey" + }, + { + "name": "liquidity_shares", + "docs": [ + "Liquidity shares of this position in bins (lower_bin_id <-> upper_bin_id). This is the same as LP concept." + ], + "type": { + "array": [ + "u128", + 70 + ] } - ] - } - }, - { - "name": "PairStatus", - "docs": [ - "Pair status. 0 = Enabled, 1 = Disabled. Putting 0 as enabled for backward compatibility." - ], - "type": { - "kind": "enum", - "variants": [ - { - "name": "Enabled" - }, - { - "name": "Disabled" + }, + { + "name": "reward_infos", + "docs": [ + "Farming reward information" + ], + "type": { + "array": [ + { + "defined": { + "name": "UserRewardInfo" + } + }, + 70 + ] } - ] - } - }, - { - "name": "TokenProgramFlags", - "type": { - "kind": "enum", - "variants": [ - { - "name": "TokenProgram" - }, - { - "name": "TokenProgram2022" + }, + { + "name": "fee_infos", + "docs": [ + "Swap fee to claim information" + ], + "type": { + "array": [ + { + "defined": { + "name": "FeeInfo" + } + }, + 70 + ] } - ] - } - }, - { - "name": "AccountsType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "TransferHookX" - }, - { - "name": "TransferHookY" - }, - { - "name": "TransferHookReward" + }, + { + "name": "lower_bin_id", + "docs": [ + "Lower bin ID" + ], + "type": "i32" + }, + { + "name": "upper_bin_id", + "docs": [ + "Upper bin ID" + ], + "type": "i32" + }, + { + "name": "last_updated_at", + "docs": [ + "Last updated timestamp" + ], + "type": "i64" + }, + { + "name": "total_claimed_fee_x_amount", + "docs": [ + "Total claimed token fee X" + ], + "type": "u64" + }, + { + "name": "total_claimed_fee_y_amount", + "docs": [ + "Total claimed token fee Y" + ], + "type": "u64" + }, + { + "name": "total_claimed_rewards", + "docs": [ + "Total claimed rewards" + ], + "type": { + "array": [ + "u64", + 2 + ] } - ] - } - }, - { - "name": "BinArrayBitmapExtension", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "positive_bin_array_bitmap", - "docs": [ - "Packed initialized bin array state for start_bin_index is positive" - ], - "type": { - "array": [ - { - "array": [ - "u64", - 8 - ] - }, - 12 - ] - } - }, - { - "name": "negative_bin_array_bitmap", - "docs": [ - "Packed initialized bin array state for start_bin_index is negative" - ], - "type": { - "array": [ - { - "array": [ - "u64", - 8 - ] - }, - 12 - ] - } + }, + { + "name": "operator", + "docs": [ + "Operator of position" + ], + "type": "pubkey" + }, + { + "name": "lock_release_point", + "docs": [ + "Time point which the locked liquidity can be withdraw" + ], + "type": "u64" + }, + { + "name": "_padding_0", + "docs": [ + "_padding_0, previous subjected_to_bootstrap_liquidity_locking, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + ], + "type": "u8" + }, + { + "name": "fee_owner", + "docs": [ + "Address is able to claim fee in this position, only valid for bootstrap_liquidity_position" + ], + "type": "pubkey" + }, + { + "name": "_reserved", + "docs": [ + "Reserved space for future use" + ], + "type": { + "array": [ + "u8", + 87 + ] } - ] - } + } + ] + } + }, + { + "name": "PresetParameter", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bin_step", + "docs": [ + "Bin step. Represent the price increment / decrement." + ], + "type": "u16" + }, + { + "name": "base_factor", + "docs": [ + "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" + ], + "type": "u16" + }, + { + "name": "filter_period", + "docs": [ + "Filter period determine high frequency trading time window." + ], + "type": "u16" + }, + { + "name": "decay_period", + "docs": [ + "Decay period determine when the volatile fee start decay / decrease." + ], + "type": "u16" + }, + { + "name": "reduction_factor", + "docs": [ + "Reduction factor controls the volatile fee rate decrement rate." + ], + "type": "u16" + }, + { + "name": "variable_fee_control", + "docs": [ + "Used to scale the variable fee component depending on the dynamic of the market" + ], + "type": "u32" + }, + { + "name": "max_volatility_accumulator", + "docs": [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ], + "type": "u32" + }, + { + "name": "min_bin_id", + "docs": [ + "Min bin id supported by the pool based on the configured bin step." + ], + "type": "i32" + }, + { + "name": "max_bin_id", + "docs": [ + "Max bin id supported by the pool based on the configured bin step." + ], + "type": "i32" + }, + { + "name": "protocol_share", + "docs": [ + "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + ], + "type": "u16" + } + ] + } + }, + { + "name": "PresetParameter2", + "serialization": "bytemuck", + "repr": { + "kind": "c" }, - { - "name": "BinArray", - "docs": [ - "An account to contain a range of bin. For example: Bin 100 <-> 200.", - "For example:", - "BinArray index: 0 contains bin 0 <-> 599", - "index: 2 contains bin 600 <-> 1199, ..." - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "index", - "type": "i64" - }, - { - "name": "version", - "docs": [ - "Version of binArray" - ], - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 7 - ] - } - }, - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "bins", - "type": { - "array": [ - { - "defined": { - "name": "Bin" - } - }, - 70 - ] - } + "type": { + "kind": "struct", + "fields": [ + { + "name": "bin_step", + "docs": [ + "Bin step. Represent the price increment / decrement." + ], + "type": "u16" + }, + { + "name": "base_factor", + "docs": [ + "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" + ], + "type": "u16" + }, + { + "name": "filter_period", + "docs": [ + "Filter period determine high frequency trading time window." + ], + "type": "u16" + }, + { + "name": "decay_period", + "docs": [ + "Decay period determine when the volatile fee start decay / decrease." + ], + "type": "u16" + }, + { + "name": "variable_fee_control", + "docs": [ + "Used to scale the variable fee component depending on the dynamic of the market" + ], + "type": "u32" + }, + { + "name": "max_volatility_accumulator", + "docs": [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ], + "type": "u32" + }, + { + "name": "reduction_factor", + "docs": [ + "Reduction factor controls the volatile fee rate decrement rate." + ], + "type": "u16" + }, + { + "name": "protocol_share", + "docs": [ + "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + ], + "type": "u16" + }, + { + "name": "index", + "docs": [ + "index" + ], + "type": "u16" + }, + { + "name": "base_fee_power_factor", + "docs": [ + "Base fee power factor" + ], + "type": "u8" + }, + { + "name": "padding_0", + "docs": [ + "Padding 0 for future use" + ], + "type": "u8" + }, + { + "name": "padding_1", + "docs": [ + "Padding 1 for future use" + ], + "type": { + "array": [ + "u64", + 20 + ] } - ] - } + } + ] + } + }, + { + "name": "ProtocolFee", + "serialization": "bytemuck", + "repr": { + "kind": "c" }, - { - "name": "ClaimFeeOperator", - "docs": [ - "Parameter that set by the protocol" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "operator", - "docs": [ - "operator" - ], - "type": "pubkey" - }, - { - "name": "padding", - "docs": [ - "Reserve" - ], - "type": { - "array": [ - "u8", - 128 - ] - } + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount_x", + "type": "u64" + }, + { + "name": "amount_y", + "type": "u64" + } + ] + } + }, + { + "name": "RebalanceLiquidityParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "active_id", + "docs": [ + "active id" + ], + "type": "i32" + }, + { + "name": "max_active_bin_slippage", + "docs": [ + "max active bin slippage allowed" + ], + "type": "u16" + }, + { + "name": "should_claim_fee", + "docs": [ + "a flag to indicate that whether fee should be harvested" + ], + "type": "bool" + }, + { + "name": "should_claim_reward", + "docs": [ + "a flag to indicate that whether rewards should be harvested" + ], + "type": "bool" + }, + { + "name": "min_withdraw_x_amount", + "docs": [ + "threshold for withdraw token x" + ], + "type": "u64" + }, + { + "name": "max_deposit_x_amount", + "docs": [ + "threshold for deposit token x" + ], + "type": "u64" + }, + { + "name": "min_withdraw_y_amount", + "docs": [ + "threshold for withdraw token y" + ], + "type": "u64" + }, + { + "name": "max_deposit_y_amount", + "docs": [ + "threshold for deposit token y" + ], + "type": "u64" + }, + { + "name": "shrink_mode", + "docs": [ + "shrink mode" + ], + "type": "u8" + }, + { + "name": "padding", + "docs": [ + "padding 32 bytes for future usage" + ], + "type": { + "array": [ + "u8", + 31 + ] } - ] - } - }, - { - "name": "LbPair", - "type": { - "kind": "struct", - "fields": [ - { - "name": "parameters", - "type": { - "defined": { - "name": "StaticParameters" - } - } - }, - { - "name": "v_parameters", - "type": { + }, + { + "name": "removes", + "docs": [ + "removes" + ], + "type": { + "vec": { "defined": { - "name": "VariableParameters" + "name": "RemoveLiquidityParams" } } - }, - { - "name": "bump_seed", - "type": { - "array": [ - "u8", - 1 - ] - } - }, - { - "name": "bin_step_seed", - "docs": [ - "Bin step signer seed" - ], - "type": { - "array": [ - "u8", - 2 - ] - } - }, - { - "name": "pair_type", - "docs": [ - "Type of the pair" - ], - "type": "u8" - }, - { - "name": "active_id", - "docs": [ - "Active bin id" - ], - "type": "i32" - }, - { - "name": "bin_step", - "docs": [ - "Bin step. Represent the price increment / decrement." - ], - "type": "u16" - }, - { - "name": "status", - "docs": [ - "Status of the pair. Check PairStatus enum." - ], - "type": "u8" - }, - { - "name": "require_base_factor_seed", - "docs": [ - "Require base factor seed" - ], - "type": "u8" - }, - { - "name": "base_factor_seed", - "docs": [ - "Base factor seed" - ], - "type": { - "array": [ - "u8", - 2 - ] - } - }, - { - "name": "activation_type", - "docs": [ - "Activation type" - ], - "type": "u8" - }, - { - "name": "creator_pool_on_off_control", - "docs": [ - "Allow pool creator to enable/disable pool with restricted validation. Only applicable for customizable permissionless pair type." - ], - "type": "u8" - }, - { - "name": "token_x_mint", - "docs": [ - "Token X mint" - ], - "type": "pubkey" - }, - { - "name": "token_y_mint", - "docs": [ - "Token Y mint" - ], - "type": "pubkey" - }, - { - "name": "reserve_x", - "docs": [ - "LB token X vault" - ], - "type": "pubkey" - }, - { - "name": "reserve_y", - "docs": [ - "LB token Y vault" - ], - "type": "pubkey" - }, - { - "name": "protocol_fee", - "docs": [ - "Uncollected protocol fee" - ], - "type": { + } + }, + { + "name": "adds", + "docs": [ + "adds" + ], + "type": { + "vec": { "defined": { - "name": "ProtocolFee" + "name": "AddLiquidityParams" } } - }, - { - "name": "padding1", - "docs": [ - "_padding_1, previous Fee owner, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "reward_infos", - "docs": [ - "Farming reward information" - ], - "type": { - "array": [ - { - "defined": { - "name": "RewardInfo" - } - }, - 2 - ] - } - }, - { - "name": "oracle", - "docs": [ - "Oracle pubkey" - ], - "type": "pubkey" - }, - { - "name": "bin_array_bitmap", - "docs": [ - "Packed initialized bin array state" - ], - "type": { - "array": [ - "u64", - 16 - ] - } - }, - { - "name": "last_updated_at", - "docs": [ - "Last time the pool fee parameter was updated" - ], - "type": "i64" - }, - { - "name": "padding2", - "docs": [ - "_padding_2, previous whitelisted_wallet, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "pre_activation_swap_address", - "docs": [ - "Address allowed to swap when the current point is greater than or equal to the pre-activation point. The pre-activation point is calculated as `activation_point - pre_activation_duration`." - ], - "type": "pubkey" - }, - { - "name": "base_key", - "docs": [ - "Base keypair. Only required for permission pair" - ], - "type": "pubkey" - }, - { - "name": "activation_point", - "docs": [ - "Time point to enable the pair. Only applicable for permission pair." - ], - "type": "u64" - }, - { - "name": "pre_activation_duration", - "docs": [ - "Duration before activation activation_point. Used to calculate pre-activation time point for pre_activation_swap_address" - ], - "type": "u64" - }, - { - "name": "padding3", - "docs": [ - "_padding 3 is reclaimed free space from swap_cap_deactivate_point and swap_cap_amount before, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" - ], - "type": { - "array": [ - "u8", - 8 - ] - } - }, - { - "name": "padding4", - "docs": [ - "_padding_4, previous lock_duration, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" - ], - "type": "u64" - }, - { - "name": "creator", - "docs": [ - "Pool creator" - ], - "type": "pubkey" - }, - { - "name": "token_mint_x_program_flag", - "docs": [ - "token_mint_x_program_flag" - ], - "type": "u8" - }, - { - "name": "token_mint_y_program_flag", - "docs": [ - "token_mint_y_program_flag" - ], - "type": "u8" - }, - { - "name": "reserved", - "docs": [ - "Reserved space for future use" - ], - "type": { - "array": [ - "u8", - 22 - ] - } - } - ] - } - }, - { - "name": "Oracle", - "type": { - "kind": "struct", - "fields": [ - { - "name": "idx", - "docs": [ - "Index of latest observation" - ], - "type": "u64" - }, - { - "name": "active_size", - "docs": [ - "Size of active sample. Active sample is initialized observation." - ], - "type": "u64" - }, - { - "name": "length", - "docs": [ - "Number of observations" - ], - "type": "u64" - } - ] - } - }, - { - "name": "Position", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "docs": [ - "The LB pair of this position" - ], - "type": "pubkey" - }, - { - "name": "owner", - "docs": [ - "Owner of the position. Client rely on this to to fetch their positions." - ], - "type": "pubkey" - }, - { - "name": "liquidity_shares", - "docs": [ - "Liquidity shares of this position in bins (lower_bin_id <-> upper_bin_id). This is the same as LP concept." - ], - "type": { - "array": [ - "u64", - 70 - ] - } - }, - { - "name": "reward_infos", - "docs": [ - "Farming reward information" - ], - "type": { - "array": [ - { - "defined": { - "name": "UserRewardInfo" - } - }, - 70 - ] - } - }, - { - "name": "fee_infos", - "docs": [ - "Swap fee to claim information" - ], - "type": { - "array": [ - { - "defined": { - "name": "FeeInfo" - } - }, - 70 - ] - } - }, - { - "name": "lower_bin_id", - "docs": [ - "Lower bin ID" - ], - "type": "i32" - }, - { - "name": "upper_bin_id", - "docs": [ - "Upper bin ID" - ], - "type": "i32" - }, - { - "name": "last_updated_at", - "docs": [ - "Last updated timestamp" - ], - "type": "i64" - }, - { - "name": "total_claimed_fee_x_amount", - "docs": [ - "Total claimed token fee X" - ], - "type": "u64" - }, - { - "name": "total_claimed_fee_y_amount", - "docs": [ - "Total claimed token fee Y" - ], - "type": "u64" - }, - { - "name": "total_claimed_rewards", - "docs": [ - "Total claimed rewards" - ], - "type": { - "array": [ - "u64", - 2 - ] - } - }, - { - "name": "reserved", - "docs": [ - "Reserved space for future use" - ], - "type": { - "array": [ - "u8", - 160 - ] - } - } - ] - } - }, - { - "name": "PositionV2", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "docs": [ - "The LB pair of this position" - ], - "type": "pubkey" - }, - { - "name": "owner", - "docs": [ - "Owner of the position. Client rely on this to to fetch their positions." - ], - "type": "pubkey" - }, - { - "name": "liquidity_shares", - "docs": [ - "Liquidity shares of this position in bins (lower_bin_id <-> upper_bin_id). This is the same as LP concept." - ], - "type": { - "array": [ - "u128", - 70 - ] - } - }, - { - "name": "reward_infos", - "docs": [ - "Farming reward information" - ], - "type": { - "array": [ - { - "defined": { - "name": "UserRewardInfo" - } - }, - 70 - ] - } - }, - { - "name": "fee_infos", - "docs": [ - "Swap fee to claim information" - ], - "type": { - "array": [ - { - "defined": { - "name": "FeeInfo" - } - }, - 70 - ] - } - }, - { - "name": "lower_bin_id", - "docs": [ - "Lower bin ID" - ], - "type": "i32" - }, - { - "name": "upper_bin_id", - "docs": [ - "Upper bin ID" - ], - "type": "i32" - }, - { - "name": "last_updated_at", - "docs": [ - "Last updated timestamp" - ], - "type": "i64" - }, - { - "name": "total_claimed_fee_x_amount", - "docs": [ - "Total claimed token fee X" - ], - "type": "u64" - }, - { - "name": "total_claimed_fee_y_amount", - "docs": [ - "Total claimed token fee Y" - ], - "type": "u64" - }, - { - "name": "total_claimed_rewards", - "docs": [ - "Total claimed rewards" - ], - "type": { - "array": [ - "u64", - 2 - ] - } - }, - { - "name": "operator", - "docs": [ - "Operator of position" - ], - "type": "pubkey" - }, - { - "name": "lock_release_point", - "docs": [ - "Time point which the locked liquidity can be withdraw" - ], - "type": "u64" - }, - { - "name": "padding0", - "docs": [ - "_padding_0, previous subjected_to_bootstrap_liquidity_locking, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" - ], - "type": "u8" - }, - { - "name": "fee_owner", - "docs": [ - "Address is able to claim fee in this position, only valid for bootstrap_liquidity_position" - ], - "type": "pubkey" - }, - { - "name": "reserved", - "docs": [ - "Reserved space for future use" - ], - "type": { - "array": [ - "u8", - 87 - ] - } - } - ] - } - }, - { - "name": "PresetParameter2", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bin_step", - "docs": [ - "Bin step. Represent the price increment / decrement." - ], - "type": "u16" - }, - { - "name": "base_factor", - "docs": [ - "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" - ], - "type": "u16" - }, - { - "name": "filter_period", - "docs": [ - "Filter period determine high frequency trading time window." - ], - "type": "u16" - }, - { - "name": "decay_period", - "docs": [ - "Decay period determine when the volatile fee start decay / decrease." - ], - "type": "u16" - }, - { - "name": "variable_fee_control", - "docs": [ - "Used to scale the variable fee component depending on the dynamic of the market" - ], - "type": "u32" - }, - { - "name": "max_volatility_accumulator", - "docs": [ - "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." - ], - "type": "u32" - }, - { - "name": "reduction_factor", - "docs": [ - "Reduction factor controls the volatile fee rate decrement rate." - ], - "type": "u16" - }, - { - "name": "protocol_share", - "docs": [ - "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" - }, - { - "name": "index", - "docs": [ - "index" - ], - "type": "u16" - }, - { - "name": "base_fee_power_factor", - "docs": [ - "Base fee power factor" - ], - "type": "u8" - }, - { - "name": "padding0", - "docs": [ - "Padding 0 for future use" - ], - "type": "u8" - }, - { - "name": "padding1", - "docs": [ - "Padding 1 for future use" - ], - "type": { - "array": [ - "u64", - 20 - ] - } - } - ] - } - }, - { - "name": "PresetParameter", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bin_step", - "docs": [ - "Bin step. Represent the price increment / decrement." - ], - "type": "u16" - }, - { - "name": "base_factor", - "docs": [ - "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" - ], - "type": "u16" - }, - { - "name": "filter_period", - "docs": [ - "Filter period determine high frequency trading time window." - ], - "type": "u16" - }, - { - "name": "decay_period", - "docs": [ - "Decay period determine when the volatile fee start decay / decrease." - ], - "type": "u16" - }, - { - "name": "reduction_factor", - "docs": [ - "Reduction factor controls the volatile fee rate decrement rate." - ], - "type": "u16" - }, - { - "name": "variable_fee_control", - "docs": [ - "Used to scale the variable fee component depending on the dynamic of the market" - ], - "type": "u32" - }, - { - "name": "max_volatility_accumulator", - "docs": [ - "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." - ], - "type": "u32" - }, - { - "name": "min_bin_id", - "docs": [ - "Min bin id supported by the pool based on the configured bin step." - ], - "type": "i32" - }, - { - "name": "max_bin_id", - "docs": [ - "Max bin id supported by the pool based on the configured bin step." - ], - "type": "i32" - }, - { - "name": "protocol_share", - "docs": [ - "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" - } - ] - } - }, - { - "name": "TokenBadge", - "docs": [ - "Parameter that set by the protocol" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "token_mint", - "docs": [ - "token mint" - ], - "type": "pubkey" - }, - { - "name": "padding", - "docs": [ - "Reserve" - ], - "type": { - "array": [ - "u8", - 128 - ] - } - } - ] - } - }, - { - "name": "CompositionFee", - "type": { - "kind": "struct", - "fields": [ - { - "name": "from", - "type": "pubkey" - }, - { - "name": "bin_id", - "type": "i16" - }, - { - "name": "token_x_fee_amount", - "type": "u64" - }, - { - "name": "token_y_fee_amount", - "type": "u64" - }, - { - "name": "protocol_token_x_fee_amount", - "type": "u64" - }, - { - "name": "protocol_token_y_fee_amount", - "type": "u64" - } - ] - } - }, - { - "name": "AddLiquidity", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "from", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "amounts", - "type": { - "array": [ - "u64", - 2 - ] - } - }, - { - "name": "active_bin_id", - "type": "i32" - } - ] - } - }, - { - "name": "RemoveLiquidity", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "from", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "amounts", - "type": { - "array": [ - "u64", - 2 - ] - } - }, - { - "name": "active_bin_id", - "type": "i32" - } - ] - } - }, - { - "name": "Swap", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "from", - "type": "pubkey" - }, - { - "name": "start_bin_id", - "type": "i32" - }, - { - "name": "end_bin_id", - "type": "i32" - }, - { - "name": "amount_in", - "type": "u64" - }, - { - "name": "amount_out", - "type": "u64" - }, - { - "name": "swap_for_y", - "type": "bool" - }, - { - "name": "fee", - "type": "u64" - }, - { - "name": "protocol_fee", - "type": "u64" - }, - { - "name": "fee_bps", - "type": "u128" - }, - { - "name": "host_fee", - "type": "u64" - } - ] - } - }, - { - "name": "ClaimReward", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "reward_index", - "type": "u64" - }, - { - "name": "total_reward", - "type": "u64" - } - ] - } - }, - { - "name": "FundReward", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "funder", - "type": "pubkey" - }, - { - "name": "reward_index", - "type": "u64" - }, - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "InitializeReward", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "reward_mint", - "type": "pubkey" - }, - { - "name": "funder", - "type": "pubkey" - }, - { - "name": "reward_index", - "type": "u64" - }, - { - "name": "reward_duration", - "type": "u64" - } - ] - } - }, - { - "name": "UpdateRewardDuration", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "reward_index", - "type": "u64" - }, - { - "name": "old_reward_duration", - "type": "u64" - }, - { - "name": "new_reward_duration", - "type": "u64" - } - ] - } - }, - { - "name": "UpdateRewardFunder", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "reward_index", - "type": "u64" - }, - { - "name": "old_funder", - "type": "pubkey" - }, - { - "name": "new_funder", - "type": "pubkey" - } - ] - } - }, - { - "name": "PositionClose", - "type": { - "kind": "struct", - "fields": [ - { - "name": "position", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "ClaimFee", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "fee_x", - "type": "u64" - }, - { - "name": "fee_y", - "type": "u64" } - ] - } - }, - { - "name": "LbPairCreate", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "bin_step", - "type": "u16" - }, - { - "name": "token_x", - "type": "pubkey" - }, - { - "name": "token_y", - "type": "pubkey" + } + ] + } + }, + { + "name": "Rebalancing", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lb_pair", + "type": "pubkey" + }, + { + "name": "position", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "active_bin_id", + "type": "i32" + }, + { + "name": "x_withdrawn_amount", + "type": "u64" + }, + { + "name": "x_added_amount", + "type": "u64" + }, + { + "name": "y_withdrawn_amount", + "type": "u64" + }, + { + "name": "y_added_amount", + "type": "u64" + }, + { + "name": "x_fee_amount", + "type": "u64" + }, + { + "name": "y_fee_amount", + "type": "u64" + }, + { + "name": "old_min_id", + "type": "i32" + }, + { + "name": "old_max_id", + "type": "i32" + }, + { + "name": "new_min_id", + "type": "i32" + }, + { + "name": "new_max_id", + "type": "i32" + }, + { + "name": "rewards", + "type": { + "array": [ + "u64", + 2 + ] } - ] - } - }, - { - "name": "PositionCreate", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" + } + ] + } + }, + { + "name": "RemainingAccountsInfo", + "type": { + "kind": "struct", + "fields": [ + { + "name": "slices", + "type": { + "vec": { + "defined": { + "name": "RemainingAccountsSlice" + } + } } - ] - } - }, - { - "name": "IncreasePositionLength", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "length_to_add", - "type": "u16" - }, - { - "name": "side", - "type": "u8" + } + ] + } + }, + { + "name": "RemainingAccountsSlice", + "type": { + "kind": "struct", + "fields": [ + { + "name": "accounts_type", + "type": { + "defined": { + "name": "AccountsType" + } } - ] - } - }, - { - "name": "DecreasePositionLength", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "position", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "length_to_remove", - "type": "u16" - }, - { - "name": "side", - "type": "u8" + }, + { + "name": "length", + "type": "u8" + } + ] + } + }, + { + "name": "RemoveLiquidity", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lb_pair", + "type": "pubkey" + }, + { + "name": "from", + "type": "pubkey" + }, + { + "name": "position", + "type": "pubkey" + }, + { + "name": "amounts", + "type": { + "array": [ + "u64", + 2 + ] } - ] - } - }, - { - "name": "FeeParameterUpdate", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "protocol_share", - "type": "u16" - }, - { - "name": "base_factor", - "type": "u16" + }, + { + "name": "active_bin_id", + "type": "i32" + } + ] + } + }, + { + "name": "RemoveLiquidityParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "min_bin_id", + "type": { + "option": "i32" } - ] - } - }, - { - "name": "DynamicFeeParameterUpdate", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "filter_period", - "type": "u16" - }, - { - "name": "decay_period", - "type": "u16" - }, - { - "name": "reduction_factor", - "type": "u16" - }, - { - "name": "variable_fee_control", - "type": "u32" - }, - { - "name": "max_volatility_accumulator", - "type": "u32" + }, + { + "name": "max_bin_id", + "type": { + "option": "i32" } - ] - } - }, - { - "name": "IncreaseObservation", - "type": { - "kind": "struct", - "fields": [ - { - "name": "oracle", - "type": "pubkey" - }, - { - "name": "new_observation_length", - "type": "u64" + }, + { + "name": "bps", + "type": "u16" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 16 + ] } - ] - } + } + ] + } + }, + { + "name": "ResizeSide", + "docs": [ + "Side of resize, 0 for lower and 1 for upper" + ], + "repr": { + "kind": "rust" }, - { - "name": "WithdrawIneligibleReward", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "reward_mint", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" + "type": { + "kind": "enum", + "variants": [ + { + "name": "Lower" + }, + { + "name": "Upper" + } + ] + } + }, + { + "name": "RewardInfo", + "docs": [ + "Stores the state relevant for tracking liquidity mining rewards" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "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": [ + "LM reward duration in seconds." + ], + "type": "u64" + }, + { + "name": "reward_duration_end", + "docs": [ + "LM reward duration end time." + ], + "type": "u64" + }, + { + "name": "reward_rate", + "docs": [ + "LM reward rate" + ], + "type": "u128" + }, + { + "name": "last_update_time", + "docs": [ + "The last time reward states were updated." + ], + "type": "u64" + }, + { + "name": "cumulative_seconds_with_empty_liquidity_reward", + "docs": [ + "Accumulated seconds where when farm distribute rewards, but the bin is empty. The reward will be accumulated for next reward time window." + ], + "type": "u64" + } + ] + } + }, + { + "name": "Rounding", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Up" + }, + { + "name": "Down" + } + ] + } + }, + { + "name": "StaticParameters", + "docs": [ + "Parameter that set by the protocol" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "base_factor", + "docs": [ + "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" + ], + "type": "u16" + }, + { + "name": "filter_period", + "docs": [ + "Filter period determine high frequency trading time window." + ], + "type": "u16" + }, + { + "name": "decay_period", + "docs": [ + "Decay period determine when the volatile fee start decay / decrease." + ], + "type": "u16" + }, + { + "name": "reduction_factor", + "docs": [ + "Reduction factor controls the volatile fee rate decrement rate." + ], + "type": "u16" + }, + { + "name": "variable_fee_control", + "docs": [ + "Used to scale the variable fee component depending on the dynamic of the market" + ], + "type": "u32" + }, + { + "name": "max_volatility_accumulator", + "docs": [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ], + "type": "u32" + }, + { + "name": "min_bin_id", + "docs": [ + "Min bin id supported by the pool based on the configured bin step." + ], + "type": "i32" + }, + { + "name": "max_bin_id", + "docs": [ + "Max bin id supported by the pool based on the configured bin step." + ], + "type": "i32" + }, + { + "name": "protocol_share", + "docs": [ + "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + ], + "type": "u16" + }, + { + "name": "base_fee_power_factor", + "docs": [ + "Base fee power factor" + ], + "type": "u8" + }, + { + "name": "_padding", + "docs": [ + "Padding for bytemuck safe alignment" + ], + "type": { + "array": [ + "u8", + 5 + ] } - ] - } - }, - { - "name": "UpdatePositionOperator", - "type": { - "kind": "struct", - "fields": [ - { - "name": "position", - "type": "pubkey" - }, - { - "name": "old_operator", - "type": "pubkey" - }, - { - "name": "new_operator", - "type": "pubkey" + } + ] + } + }, + { + "name": "StrategyParameters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "min_bin_id", + "docs": [ + "min bin id" + ], + "type": "i32" + }, + { + "name": "max_bin_id", + "docs": [ + "max bin id" + ], + "type": "i32" + }, + { + "name": "strategy_type", + "docs": [ + "strategy type" + ], + "type": { + "defined": { + "name": "StrategyType" + } } - ] - } - }, - { - "name": "UpdatePositionLockReleasePoint", - "type": { - "kind": "struct", - "fields": [ - { - "name": "position", - "type": "pubkey" - }, - { - "name": "current_point", - "type": "u64" - }, - { - "name": "new_lock_release_point", - "type": "u64" - }, - { - "name": "old_lock_release_point", - "type": "u64" - }, - { - "name": "sender", - "type": "pubkey" + }, + { + "name": "parameteres", + "docs": [ + "parameters" + ], + "type": { + "array": [ + "u8", + 64 + ] } - ] - } - }, - { - "name": "GoToABin", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lb_pair", - "type": "pubkey" - }, - { - "name": "from_bin_id", - "type": "i32" - }, - { - "name": "to_bin_id", - "type": "i32" + } + ] + } + }, + { + "name": "StrategyType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "SpotOneSide" + }, + { + "name": "CurveOneSide" + }, + { + "name": "BidAskOneSide" + }, + { + "name": "SpotBalanced" + }, + { + "name": "CurveBalanced" + }, + { + "name": "BidAskBalanced" + }, + { + "name": "SpotImBalanced" + }, + { + "name": "CurveImBalanced" + }, + { + "name": "BidAskImBalanced" + } + ] + } + }, + { + "name": "Swap", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lb_pair", + "type": "pubkey" + }, + { + "name": "from", + "type": "pubkey" + }, + { + "name": "start_bin_id", + "type": "i32" + }, + { + "name": "end_bin_id", + "type": "i32" + }, + { + "name": "amount_in", + "type": "u64" + }, + { + "name": "amount_out", + "type": "u64" + }, + { + "name": "swap_for_y", + "type": "bool" + }, + { + "name": "fee", + "type": "u64" + }, + { + "name": "protocol_fee", + "type": "u64" + }, + { + "name": "fee_bps", + "type": "u128" + }, + { + "name": "host_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 + ] } - ] - } + } + ] } - ], - "constants": [ - { - "name": "BASIS_POINT_MAX", - "type": "i32", - "value": "10000" + }, + { + "name": "TokenProgramFlags", + "repr": { + "kind": "rust" }, - { - "name": "MAX_BIN_PER_ARRAY", - "type": { - "defined": { - "name": "usize" + "type": { + "kind": "enum", + "variants": [ + { + "name": "TokenProgram" + }, + { + "name": "TokenProgram2022" } - }, - "value": "70" - }, - { - "name": "MAX_BIN_PER_POSITION", - "type": { - "defined": { - "name": "usize" + ] + } + }, + { + "name": "UpdatePositionLockReleasePoint", + "type": { + "kind": "struct", + "fields": [ + { + "name": "position", + "type": "pubkey" + }, + { + "name": "current_point", + "type": "u64" + }, + { + "name": "new_lock_release_point", + "type": "u64" + }, + { + "name": "old_lock_release_point", + "type": "u64" + }, + { + "name": "sender", + "type": "pubkey" } - }, - "value": "70" - }, - { - "name": "MAX_RESIZE_LENGTH", - "type": { - "defined": { - "name": "usize" + ] + } + }, + { + "name": "UpdatePositionOperator", + "type": { + "kind": "struct", + "fields": [ + { + "name": "position", + "type": "pubkey" + }, + { + "name": "old_operator", + "type": "pubkey" + }, + { + "name": "new_operator", + "type": "pubkey" } - }, - "value": "70" - }, - { - "name": "POSITION_MAX_LENGTH", - "type": { - "defined": { - "name": "usize" + ] + } + }, + { + "name": "UpdateRewardDuration", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lb_pair", + "type": "pubkey" + }, + { + "name": "reward_index", + "type": "u64" + }, + { + "name": "old_reward_duration", + "type": "u64" + }, + { + "name": "new_reward_duration", + "type": "u64" } - }, - "value": "1400" - }, - { - "name": "MIN_BIN_ID", - "type": "i32", - "value": "- 443636" - }, - { - "name": "MAX_BIN_ID", - "type": "i32", - "value": "443636" - }, - { - "name": "MAX_FEE_RATE", - "type": "u64", - "value": "100_000_000" - }, - { - "name": "FEE_PRECISION", - "type": "u64", - "value": "1_000_000_000" - }, - { - "name": "MAX_PROTOCOL_SHARE", - "type": "u16", - "value": "2_500" - }, - { - "name": "HOST_FEE_BPS", - "type": "u16", - "value": "2_000" - }, - { - "name": "NUM_REWARDS", - "type": { - "defined": { - "name": "usize" + ] + } + }, + { + "name": "UpdateRewardFunder", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lb_pair", + "type": "pubkey" + }, + { + "name": "reward_index", + "type": "u64" + }, + { + "name": "old_funder", + "type": "pubkey" + }, + { + "name": "new_funder", + "type": "pubkey" } - }, - "value": "2" - }, - { - "name": "MIN_REWARD_DURATION", - "type": "u64", - "value": "1" - }, - { - "name": "MAX_REWARD_DURATION", - "type": "u64", - "value": "31536000" + ] + } + }, + { + "name": "UserRewardInfo", + "serialization": "bytemuck", + "repr": { + "kind": "c" }, - { - "name": "EXTENSION_BINARRAY_BITMAP_SIZE", - "type": { - "defined": { - "name": "usize" + "type": { + "kind": "struct", + "fields": [ + { + "name": "reward_per_token_completes", + "type": { + "array": [ + "u128", + 2 + ] + } + }, + { + "name": "reward_pendings", + "type": { + "array": [ + "u64", + 2 + ] + } } - }, - "value": "12" - }, - { - "name": "BIN_ARRAY_BITMAP_SIZE", - "type": "i32", - "value": "512" - }, - { - "name": "MAX_REWARD_BIN_SPLIT", - "type": { - "defined": { - "name": "usize" + ] + } + }, + { + "name": "VariableParameters", + "docs": [ + "Parameters that changes based on dynamic of the market" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "volatility_accumulator", + "docs": [ + "Volatility accumulator measure the number of bin crossed since reference bin ID. Normally (without filter period taken into consideration), reference bin ID is the active bin of last swap.", + "It affects the variable fee rate" + ], + "type": "u32" + }, + { + "name": "volatility_reference", + "docs": [ + "Volatility reference is decayed volatility accumulator. It is always <= volatility_accumulator" + ], + "type": "u32" + }, + { + "name": "index_reference", + "docs": [ + "Active bin id of last swap." + ], + "type": "i32" + }, + { + "name": "_padding", + "docs": [ + "Padding for bytemuck safe alignment" + ], + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "last_update_timestamp", + "docs": [ + "Last timestamp the variable parameters was updated" + ], + "type": "i64" + }, + { + "name": "_padding_1", + "docs": [ + "Padding for bytemuck safe alignment" + ], + "type": { + "array": [ + "u8", + 8 + ] + } } - }, - "value": "15" - }, - { - "name": "ILM_PROTOCOL_SHARE", - "type": "u16", - "value": "2000" - }, - { - "name": "PROTOCOL_SHARE", - "type": "u16", - "value": "500" - }, - { - "name": "MAX_BIN_STEP", - "type": "u16", - "value": "400" - }, - { - "name": "MAX_BASE_FEE", - "type": "u128", - "value": "100_000_000" - }, - { - "name": "MIN_BASE_FEE", - "type": "u128", - "value": "100_000" - }, - { - "name": "MINIMUM_LIQUIDITY", - "type": "u128", - "value": "1_000_000" - }, - { - "name": "BIN_ARRAY", - "type": "bytes", - "value": "[98, 105, 110, 95, 97, 114, 114, 97, 121]" - }, - { - "name": "ORACLE", - "type": "bytes", - "value": "[111, 114, 97, 99, 108, 101]" - }, - { - "name": "BIN_ARRAY_BITMAP_SEED", - "type": "bytes", - "value": "[98, 105, 116, 109, 97, 112]" - }, - { - "name": "PRESET_PARAMETER", - "type": "bytes", - "value": "[112, 114, 101, 115, 101, 116, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114]" - }, - { - "name": "PRESET_PARAMETER2", - "type": "bytes", - "value": "[112, 114, 101, 115, 101, 116, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114, 50]" - }, - { - "name": "POSITION", - "type": "bytes", - "value": "[112, 111, 115, 105, 116, 105, 111, 110]" - }, - { - "name": "CLAIM_PROTOCOL_FEE_OPERATOR", - "type": "bytes", - "value": "[99, 102, 95, 111, 112, 101, 114, 97, 116, 111, 114]" + ] + } + }, + { + "name": "WithdrawIneligibleReward", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lb_pair", + "type": "pubkey" + }, + { + "name": "reward_mint", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + } + ] } - ] - } \ No newline at end of file + } + ], + "constants": [ + { + "name": "BASIS_POINT_MAX", + "type": "i32", + "value": "10000" + }, + { + "name": "BIN_ARRAY", + "type": "bytes", + "value": "[98, 105, 110, 95, 97, 114, 114, 97, 121]" + }, + { + "name": "BIN_ARRAY_BITMAP_SEED", + "type": "bytes", + "value": "[98, 105, 116, 109, 97, 112]" + }, + { + "name": "BIN_ARRAY_BITMAP_SIZE", + "type": "i32", + "value": "512" + }, + { + "name": "CLAIM_PROTOCOL_FEE_OPERATOR", + "type": "bytes", + "value": "[99, 102, 95, 111, 112, 101, 114, 97, 116, 111, 114]" + }, + { + "name": "DEFAULT_BIN_PER_POSITION", + "type": "u64", + "value": "70" + }, + { + "name": "EXTENSION_BINARRAY_BITMAP_SIZE", + "type": "u64", + "value": "12" + }, + { + "name": "FEE_PRECISION", + "type": "u64", + "value": "1000000000" + }, + { + "name": "HOST_FEE_BPS", + "docs": [ + "Host fee. 20%" + ], + "type": "u16", + "value": "2000" + }, + { + "name": "ILM_PROTOCOL_SHARE", + "type": "u16", + "value": "2000" + }, + { + "name": "MAX_BASE_FEE", + "docs": [ + "Maximum base fee, base_fee / 10^9 = fee_in_percentage" + ], + "type": "u128", + "value": "100000000" + }, + { + "name": "MAX_BIN_ID", + "docs": [ + "Maximum bin ID supported. Computed based on 1 bps." + ], + "type": "i32", + "value": "443636" + }, + { + "name": "MAX_BIN_PER_ARRAY", + "type": "u64", + "value": "70" + }, + { + "name": "MAX_BIN_STEP", + "docs": [ + "Maximum bin step" + ], + "type": "u16", + "value": "400" + }, + { + "name": "MAX_FEE_RATE", + "docs": [ + "Maximum fee rate. 10%" + ], + "type": "u64", + "value": "100000000" + }, + { + "name": "MAX_PROTOCOL_SHARE", + "docs": [ + "Maximum protocol share of the fee. 25%" + ], + "type": "u16", + "value": "2500" + }, + { + "name": "MAX_RESIZE_LENGTH", + "type": "u64", + "value": "91" + }, + { + "name": "MAX_REWARD_BIN_SPLIT", + "type": "u64", + "value": "15" + }, + { + "name": "MAX_REWARD_DURATION", + "type": "u64", + "value": "31536000" + }, + { + "name": "MINIMUM_LIQUIDITY", + "type": "u128", + "value": "1000000" + }, + { + "name": "MIN_BASE_FEE", + "docs": [ + "Minimum base fee" + ], + "type": "u128", + "value": "100000" + }, + { + "name": "MIN_BIN_ID", + "docs": [ + "Minimum bin ID supported. Computed based on 1 bps." + ], + "type": "i32", + "value": "-443636" + }, + { + "name": "MIN_REWARD_DURATION", + "type": "u64", + "value": "1" + }, + { + "name": "NUM_REWARDS", + "type": "u64", + "value": "2" + }, + { + "name": "ORACLE", + "type": "bytes", + "value": "[111, 114, 97, 99, 108, 101]" + }, + { + "name": "POSITION", + "type": "bytes", + "value": "[112, 111, 115, 105, 116, 105, 111, 110]" + }, + { + "name": "POSITION_MAX_LENGTH", + "type": "u64", + "value": "1400" + }, + { + "name": "PRESET_PARAMETER", + "type": "bytes", + "value": "[112, 114, 101, 115, 101, 116, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114]" + }, + { + "name": "PRESET_PARAMETER2", + "type": "bytes", + "value": "[112, 114, 101, 115, 101, 116, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114, 50]" + }, + { + "name": "PROTOCOL_SHARE", + "type": "u16", + "value": "500" + } + ] +} \ No newline at end of file diff --git a/tests/common/idl/dlmm.ts b/tests/common/idl/dlmm.ts index 2b3c552..3f80146 100644 --- a/tests/common/idl/dlmm.ts +++ b/tests/common/idl/dlmm.ts @@ -5,7626 +5,9377 @@ * IDL can be found at `target/idl/lb_clmm.json`. */ export type LbClmm = { - "address": "LbVRzDTvBDEcrthxfZ4RL6yiq3uZw8bS6MwtdY6UhFQ", - "metadata": { - "name": "lbClmm", - "version": "0.9.1", - "spec": "0.1.0" - }, - "instructions": [ + address: "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo"; + metadata: { + name: "lbClmm"; + version: "0.10.1"; + spec: "0.1.0"; + description: "Created with Anchor"; + }; + instructions: [ { - "name": "initializeLbPair", - "discriminator": [ - 45, - 154, - 237, - 210, - 221, - 15, - 166, - 92 - ], - "accounts": [ + name: "addLiquidity"; + discriminator: [181, 157, 89, 67, 143, 182, 52, 72]; + accounts: [ { - "name": "lbPair", - "writable": true + name: "position"; + writable: true; }, { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "lbPair"; + writable: true; + relations: [ + "position", + "binArrayBitmapExtension", + "binArrayLower", + "binArrayUpper" + ]; }, { - "name": "tokenMintX" + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "tokenMintY" + name: "userTokenX"; + writable: true; }, { - "name": "reserveX", - "writable": true + name: "userTokenY"; + writable: true; }, { - "name": "reserveY", - "writable": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "oracle", - "writable": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "presetParameter" + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "funder", - "writable": true, - "signer": true + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "tokenProgram" + name: "binArrayLower"; + writable: true; }, { - "name": "systemProgram" + name: "binArrayUpper"; + writable: true; }, { - "name": "rent" + name: "sender"; + signer: true; }, { - "name": "eventAuthority" + name: "tokenXProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "program" - } - ], - "args": [ + name: "tokenYProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, { - "name": "activeId", - "type": "i32" + 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": "binStep", - "type": "u16" + name: "program"; + } + ]; + args: [ + { + name: "liquidityParameter"; + type: { + defined: { + name: "liquidityParameter"; + }; + }; } - ] + ]; }, { - "name": "initializePermissionLbPair", - "discriminator": [ - 108, - 102, - 213, - 85, - 251, - 3, - 53, - 21 - ], - "accounts": [ - { - "name": "base", - "signer": true - }, - { - "name": "lbPair", - "writable": true - }, + name: "addLiquidity2"; + discriminator: [228, 162, 78, 28, 70, 219, 116, 115]; + accounts: [ { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "position"; + writable: true; }, { - "name": "tokenMintX" + name: "lbPair"; + writable: true; + relations: ["position", "binArrayBitmapExtension"]; }, { - "name": "tokenMintY" + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "reserveX", - "writable": true + name: "userTokenX"; + writable: true; }, { - "name": "reserveY", - "writable": true + name: "userTokenY"; + writable: true; }, { - "name": "oracle", - "writable": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "admin", - "writable": true, - "signer": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "tokenBadgeX", - "optional": true + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "tokenBadgeY", - "optional": true + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "tokenProgramX" + name: "sender"; + signer: true; }, { - "name": "tokenProgramY" + name: "tokenXProgram"; }, { - "name": "systemProgram" + name: "tokenYProgram"; }, { - "name": "rent" - }, - { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [ - { - "name": "ixData", - "type": { - "defined": { - "name": "initPermissionPairIx" - } - } + ]; + args: [ + { + name: "liquidityParameter"; + type: { + defined: { + name: "liquidityParameter"; + }; + }; + }, + { + name: "remainingAccountsInfo"; + type: { + defined: { + name: "remainingAccountsInfo"; + }; + }; } - ] + ]; }, { - "name": "initializeCustomizablePermissionlessLbPair", - "discriminator": [ - 46, - 39, - 41, - 135, - 111, - 183, - 200, - 64 - ], - "accounts": [ + name: "addLiquidityByStrategy"; + discriminator: [7, 3, 150, 127, 148, 40, 61, 200]; + accounts: [ + { + name: "position"; + writable: true; + }, + { + name: "lbPair"; + writable: true; + relations: [ + "position", + "binArrayBitmapExtension", + "binArrayLower", + "binArrayUpper" + ]; + }, { - "name": "lbPair", - "writable": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "userTokenX"; + writable: true; }, { - "name": "tokenMintX" + name: "userTokenY"; + writable: true; }, { - "name": "tokenMintY" + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "reserveX", - "writable": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "reserveY", - "writable": true + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "oracle", - "writable": true + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "userTokenX" + name: "binArrayLower"; + writable: true; }, { - "name": "funder", - "writable": true, - "signer": true + name: "binArrayUpper"; + writable: true; }, { - "name": "tokenProgram" + name: "sender"; + signer: true; }, { - "name": "systemProgram" + name: "tokenXProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "userTokenY" + name: "tokenYProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "customizableParams" - } - } + ]; + args: [ + { + name: "liquidityParameter"; + type: { + defined: { + name: "liquidityParameterByStrategy"; + }; + }; } - ] + ]; }, { - "name": "initializeBinArrayBitmapExtension", - "discriminator": [ - 47, - 157, - 226, - 180, - 12, - 240, - 33, - 71 - ], - "accounts": [ + name: "addLiquidityByStrategy2"; + discriminator: [3, 221, 149, 218, 111, 141, 118, 213]; + accounts: [ { - "name": "lbPair" + name: "position"; + writable: true; }, { - "name": "binArrayBitmapExtension", - "docs": [ - "Initialize an account to store if a bin array is initialized." - ], - "writable": true + name: "lbPair"; + writable: true; + relations: ["position", "binArrayBitmapExtension"]; }, { - "name": "funder", - "writable": true, - "signer": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "systemProgram" + name: "userTokenX"; + writable: true; }, { - "name": "rent" - } - ], - "args": [] - }, - { - "name": "initializeBinArray", - "discriminator": [ - 35, - 86, - 19, - 185, - 78, - 212, - 75, - 211 - ], - "accounts": [ - { - "name": "lbPair" + name: "userTokenY"; + writable: true; }, { - "name": "binArray", - "writable": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "funder", - "writable": true, - "signer": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "systemProgram" - } - ], - "args": [ + name: "tokenXMint"; + relations: ["lbPair"]; + }, { - "name": "index", - "type": "i64" - } - ] - }, - { - "name": "addLiquidity", - "discriminator": [ - 181, - 157, - 89, - 67, - 143, - 182, - 52, - 72 - ], - "accounts": [ + name: "tokenYMint"; + relations: ["lbPair"]; + }, { - "name": "position", - "writable": true + name: "sender"; + signer: true; }, { - "name": "lbPair", - "writable": true + name: "tokenXProgram"; }, { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "tokenYProgram"; }, { - "name": "userTokenX", - "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": "userTokenY", - "writable": true + name: "program"; + } + ]; + args: [ + { + name: "liquidityParameter"; + type: { + defined: { + name: "liquidityParameterByStrategy"; + }; + }; + }, + { + name: "remainingAccountsInfo"; + type: { + defined: { + name: "remainingAccountsInfo"; + }; + }; + } + ]; + }, + { + name: "addLiquidityByStrategyOneSide"; + discriminator: [41, 5, 238, 175, 100, 225, 6, 205]; + accounts: [ + { + name: "position"; + writable: true; }, { - "name": "reserveX", - "writable": true + name: "lbPair"; + writable: true; + relations: [ + "position", + "binArrayBitmapExtension", + "binArrayLower", + "binArrayUpper" + ]; }, { - "name": "reserveY", - "writable": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "tokenXMint" + name: "userToken"; + writable: true; }, { - "name": "tokenYMint" + name: "reserve"; + writable: true; }, { - "name": "binArrayLower", - "writable": true + name: "tokenMint"; }, { - "name": "binArrayUpper", - "writable": true + name: "binArrayLower"; + writable: true; }, { - "name": "sender", - "signer": true + name: "binArrayUpper"; + writable: true; }, { - "name": "tokenXProgram" + name: "sender"; + signer: true; }, { - "name": "tokenYProgram" + name: "tokenProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": { - "name": "liquidityParameter" - } - } + ]; + args: [ + { + name: "liquidityParameter"; + type: { + defined: { + name: "liquidityParameterByStrategyOneSide"; + }; + }; } - ] + ]; }, { - "name": "addLiquidityByWeight", - "discriminator": [ - 28, - 140, - 238, - 99, - 231, - 162, - 21, - 149 - ], - "accounts": [ + name: "addLiquidityByWeight"; + discriminator: [28, 140, 238, 99, 231, 162, 21, 149]; + accounts: [ { - "name": "position", - "writable": true + name: "position"; + writable: true; }, { - "name": "lbPair", - "writable": true + name: "lbPair"; + writable: true; + relations: [ + "position", + "binArrayBitmapExtension", + "binArrayLower", + "binArrayUpper" + ]; }, { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "userTokenX", - "writable": true + name: "userTokenX"; + writable: true; }, { - "name": "userTokenY", - "writable": true + name: "userTokenY"; + writable: true; }, { - "name": "reserveX", - "writable": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "reserveY", - "writable": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "tokenXMint" + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "tokenYMint" + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "binArrayLower", - "writable": true + name: "binArrayLower"; + writable: true; }, { - "name": "binArrayUpper", - "writable": true + name: "binArrayUpper"; + writable: true; }, { - "name": "sender", - "signer": true + name: "sender"; + signer: true; }, { - "name": "tokenXProgram" + name: "tokenXProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "tokenYProgram" + name: "tokenYProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": { - "name": "liquidityParameterByWeight" - } - } + ]; + args: [ + { + name: "liquidityParameter"; + type: { + defined: { + name: "liquidityParameterByWeight"; + }; + }; } - ] + ]; }, { - "name": "addLiquidityByStrategy", - "discriminator": [ - 7, - 3, - 150, - 127, - 148, - 40, - 61, - 200 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lbPair", - "writable": true - }, - { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true - }, - { - "name": "userTokenX", - "writable": true - }, + name: "addLiquidityOneSide"; + discriminator: [94, 155, 103, 151, 70, 95, 220, 165]; + accounts: [ { - "name": "userTokenY", - "writable": true + name: "position"; + writable: true; }, { - "name": "reserveX", - "writable": true + name: "lbPair"; + writable: true; + relations: [ + "position", + "binArrayBitmapExtension", + "binArrayLower", + "binArrayUpper" + ]; }, { - "name": "reserveY", - "writable": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "tokenXMint" + name: "userToken"; + writable: true; }, { - "name": "tokenYMint" + name: "reserve"; + writable: true; }, { - "name": "binArrayLower", - "writable": true + name: "tokenMint"; }, { - "name": "binArrayUpper", - "writable": true + name: "binArrayLower"; + writable: true; }, { - "name": "sender", - "signer": true + name: "binArrayUpper"; + writable: true; }, { - "name": "tokenXProgram" + name: "sender"; + signer: true; }, { - "name": "tokenYProgram" + name: "tokenProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": { - "name": "liquidityParameterByStrategy" - } - } + ]; + args: [ + { + name: "liquidityParameter"; + type: { + defined: { + name: "liquidityOneSideParameter"; + }; + }; } - ] + ]; }, { - "name": "addLiquidityByStrategyOneSide", - "discriminator": [ - 41, - 5, - 238, - 175, - 100, - 225, - 6, - 205 - ], - "accounts": [ + name: "addLiquidityOneSidePrecise"; + discriminator: [161, 194, 103, 84, 171, 71, 250, 154]; + accounts: [ { - "name": "position", - "writable": true + name: "position"; + writable: true; }, { - "name": "lbPair", - "writable": true + name: "lbPair"; + writable: true; + relations: [ + "position", + "binArrayBitmapExtension", + "binArrayLower", + "binArrayUpper" + ]; }, { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "userToken", - "writable": true + name: "userToken"; + writable: true; }, { - "name": "reserve", - "writable": true + name: "reserve"; + writable: true; }, { - "name": "tokenMint" + name: "tokenMint"; }, { - "name": "binArrayLower", - "writable": true + name: "binArrayLower"; + writable: true; }, { - "name": "binArrayUpper", - "writable": true + name: "binArrayUpper"; + writable: true; }, { - "name": "sender", - "signer": true + name: "sender"; + signer: true; }, { - "name": "tokenProgram" + name: "tokenProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": { - "name": "liquidityParameterByStrategyOneSide" - } - } + ]; + args: [ + { + name: "parameter"; + type: { + defined: { + name: "addLiquiditySingleSidePreciseParameter"; + }; + }; } - ] + ]; }, { - "name": "addLiquidityOneSide", - "discriminator": [ - 94, - 155, - 103, - 151, - 70, - 95, - 220, - 165 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lbPair", - "writable": true - }, + name: "addLiquidityOneSidePrecise2"; + discriminator: [33, 51, 163, 201, 117, 98, 125, 231]; + accounts: [ { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "position"; + writable: true; }, { - "name": "userToken", - "writable": true + name: "lbPair"; + writable: true; + relations: ["position", "binArrayBitmapExtension"]; }, { - "name": "reserve", - "writable": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "tokenMint" + name: "userToken"; + writable: true; }, { - "name": "binArrayLower", - "writable": true + name: "reserve"; + writable: true; }, { - "name": "binArrayUpper", - "writable": true + name: "tokenMint"; }, { - "name": "sender", - "signer": true + name: "sender"; + signer: true; }, { - "name": "tokenProgram" + name: "tokenProgram"; }, { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": { - "name": "liquidityOneSideParameter" - } - } + ]; + args: [ + { + name: "liquidityParameter"; + type: { + defined: { + name: "addLiquiditySingleSidePreciseParameter2"; + }; + }; + }, + { + name: "remainingAccountsInfo"; + type: { + defined: { + name: "remainingAccountsInfo"; + }; + }; } - ] + ]; }, { - "name": "removeLiquidity", - "discriminator": [ - 80, - 85, - 209, - 72, - 24, - 206, - 177, - 108 - ], - "accounts": [ + name: "claimFee"; + discriminator: [169, 32, 79, 137, 136, 232, 70, 137]; + accounts: [ { - "name": "position", - "writable": true + name: "lbPair"; + writable: true; + relations: ["position", "binArrayLower", "binArrayUpper"]; }, { - "name": "lbPair", - "writable": true + name: "position"; + writable: true; }, { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "binArrayLower"; + writable: true; }, { - "name": "userTokenX", - "writable": true + name: "binArrayUpper"; + writable: true; }, { - "name": "userTokenY", - "writable": true + name: "sender"; + signer: true; }, { - "name": "reserveX", - "writable": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "reserveY", - "writable": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "tokenXMint" + name: "userTokenX"; + writable: true; }, { - "name": "tokenYMint" + name: "userTokenY"; + writable: true; }, { - "name": "binArrayLower", - "writable": true + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "binArrayUpper", - "writable": true + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "sender", - "signer": true + name: "tokenProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "tokenXProgram" + 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": "tokenYProgram" + name: "program"; + } + ]; + args: []; + }, + { + name: "claimFee2"; + discriminator: [112, 191, 101, 171, 28, 144, 127, 187]; + accounts: [ + { + name: "lbPair"; + writable: true; + relations: ["position"]; }, { - "name": "eventAuthority" + name: "position"; + writable: true; }, { - "name": "program" - } - ], - "args": [ - { - "name": "binLiquidityRemoval", - "type": { - "vec": { - "defined": { - "name": "binLiquidityReduction" - } - } - } - } - ] - }, - { - "name": "initializePosition", - "discriminator": [ - 219, - 192, - 234, - 71, - 190, - 191, - 102, - 80 - ], - "accounts": [ + name: "sender"; + signer: true; + }, + { + name: "reserveX"; + writable: true; + relations: ["lbPair"]; + }, + { + name: "reserveY"; + writable: true; + relations: ["lbPair"]; + }, + { + name: "userTokenX"; + writable: true; + }, { - "name": "payer", - "writable": true, - "signer": true + name: "userTokenY"; + writable: true; }, { - "name": "position", - "writable": true, - "signer": true + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "lbPair" + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "owner", - "signer": true + name: "tokenProgramX"; }, { - "name": "systemProgram" + name: "tokenProgramY"; }, { - "name": "rent" + name: "memoProgram"; + address: "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"; }, { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [ + ]; + args: [ { - "name": "lowerBinId", - "type": "i32" + name: "minBinId"; + type: "i32"; }, { - "name": "width", - "type": "i32" + name: "maxBinId"; + type: "i32"; + }, + { + name: "remainingAccountsInfo"; + type: { + defined: { + name: "remainingAccountsInfo"; + }; + }; } - ] + ]; }, { - "name": "initializePositionPda", - "discriminator": [ - 46, - 82, - 125, - 146, - 85, - 141, - 228, - 153 - ], - "accounts": [ + name: "claimReward"; + discriminator: [149, 95, 181, 242, 94, 90, 158, 162]; + accounts: [ { - "name": "payer", - "writable": true, - "signer": true + name: "lbPair"; + writable: true; + relations: ["position", "binArrayLower", "binArrayUpper"]; }, { - "name": "base", - "signer": true + name: "position"; + writable: true; }, { - "name": "position", - "writable": true + name: "binArrayLower"; + writable: true; }, { - "name": "lbPair" + name: "binArrayUpper"; + writable: true; }, { - "name": "owner", - "docs": [ - "owner" - ], - "signer": true + name: "sender"; + signer: true; }, { - "name": "systemProgram" + name: "rewardVault"; + writable: true; }, { - "name": "rent" + name: "rewardMint"; }, { - "name": "eventAuthority" + name: "userTokenAccount"; + writable: true; }, { - "name": "program" - } - ], - "args": [ + name: "tokenProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, { - "name": "lowerBinId", - "type": "i32" + 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": "width", - "type": "i32" + name: "program"; + } + ]; + args: [ + { + name: "rewardIndex"; + type: "u64"; } - ] + ]; }, { - "name": "initializePositionByOperator", - "discriminator": [ - 251, - 189, - 190, - 244, - 117, - 254, - 35, - 148 - ], - "accounts": [ + name: "claimReward2"; + discriminator: [190, 3, 127, 119, 178, 87, 157, 183]; + accounts: [ { - "name": "payer", - "writable": true, - "signer": true + name: "lbPair"; + writable: true; + relations: ["position"]; }, { - "name": "base", - "signer": true + name: "position"; + writable: true; }, { - "name": "position", - "writable": true + name: "sender"; + signer: true; }, { - "name": "lbPair" + name: "rewardVault"; + writable: true; }, { - "name": "owner" + name: "rewardMint"; }, { - "name": "operator", - "docs": [ - "operator" - ], - "signer": true + name: "userTokenAccount"; + writable: true; }, { - "name": "operatorTokenX" + name: "tokenProgram"; }, { - "name": "ownerTokenX" + name: "memoProgram"; + address: "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"; }, { - "name": "systemProgram" + 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": "eventAuthority" + name: "program"; + } + ]; + args: [ + { + name: "rewardIndex"; + type: "u64"; }, { - "name": "program" - } - ], - "args": [ + name: "minBinId"; + type: "i32"; + }, { - "name": "lowerBinId", - "type": "i32" + name: "maxBinId"; + type: "i32"; }, { - "name": "width", - "type": "i32" + name: "remainingAccountsInfo"; + type: { + defined: { + name: "remainingAccountsInfo"; + }; + }; + } + ]; + }, + { + name: "closeClaimProtocolFeeOperator"; + discriminator: [8, 41, 87, 35, 80, 48, 121, 26]; + accounts: [ + { + name: "claimFeeOperator"; + writable: true; }, { - "name": "feeOwner", - "type": "pubkey" + name: "rentReceiver"; + writable: true; }, { - "name": "lockReleasePoint", - "type": "u64" + name: "admin"; + signer: true; } - ] + ]; + args: []; }, { - "name": "updatePositionOperator", - "discriminator": [ - 202, - 184, - 103, - 143, - 180, - 191, - 116, - 217 - ], - "accounts": [ + name: "closePosition"; + discriminator: [123, 134, 81, 0, 49, 68, 98, 98]; + accounts: [ { - "name": "position", - "writable": true + name: "position"; + writable: true; }, { - "name": "owner", - "signer": true + name: "lbPair"; + writable: true; + relations: ["position", "binArrayLower", "binArrayUpper"]; }, { - "name": "eventAuthority" + name: "binArrayLower"; + writable: true; }, { - "name": "program" - } - ], - "args": [ + name: "binArrayUpper"; + writable: true; + }, { - "name": "operator", - "type": "pubkey" - } - ] - }, - { - "name": "swap", - "discriminator": [ - 248, - 198, - 158, - 145, - 225, - 117, - 135, - 200 - ], - "accounts": [ + name: "sender"; + signer: true; + }, { - "name": "lbPair", - "writable": true + name: "rentReceiver"; + writable: true; }, { - "name": "binArrayBitmapExtension", - "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": "reserveX", - "writable": true + name: "program"; + } + ]; + args: []; + }, + { + name: "closePosition2"; + discriminator: [174, 90, 35, 115, 186, 40, 147, 226]; + accounts: [ + { + name: "position"; + writable: true; + }, + { + name: "sender"; + 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": "reserveY", - "writable": true + name: "program"; + } + ]; + args: []; + }, + { + name: "closePositionIfEmpty"; + discriminator: [59, 124, 212, 118, 91, 152, 110, 157]; + accounts: [ + { + name: "position"; + writable: true; + }, + { + name: "sender"; + 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": "userTokenIn", - "writable": true + name: "program"; + } + ]; + args: []; + }, + { + name: "closePresetParameter"; + discriminator: [4, 148, 145, 100, 134, 26, 181, 61]; + accounts: [ + { + name: "presetParameter"; + writable: true; }, { - "name": "userTokenOut", - "writable": true + name: "admin"; + writable: true; + signer: true; }, { - "name": "tokenXMint" + name: "rentReceiver"; + writable: true; + } + ]; + args: []; + }, + { + name: "closePresetParameter2"; + discriminator: [39, 25, 95, 107, 116, 17, 115, 28]; + accounts: [ + { + name: "presetParameter"; + writable: true; }, { - "name": "tokenYMint" + name: "admin"; + writable: true; + signer: true; }, { - "name": "oracle", - "writable": true + name: "rentReceiver"; + writable: true; + } + ]; + args: []; + }, + { + name: "closeTokenBadge"; + discriminator: [108, 146, 86, 110, 179, 254, 10, 104]; + accounts: [ + { + name: "tokenBadge"; + writable: true; }, { - "name": "hostFeeIn", - "writable": true, - "optional": true + name: "rentReceiver"; + writable: true; }, { - "name": "user", - "signer": true + name: "admin"; + signer: true; + } + ]; + args: []; + }, + { + name: "createClaimProtocolFeeOperator"; + discriminator: [51, 19, 150, 252, 105, 157, 48, 91]; + 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": "tokenXProgram" + name: "operator"; }, { - "name": "tokenYProgram" + name: "admin"; + writable: true; + signer: true; }, { - "name": "eventAuthority" + name: "systemProgram"; + address: "11111111111111111111111111111111"; + } + ]; + args: []; + }, + { + name: "decreasePositionLength"; + discriminator: [194, 219, 136, 32, 25, 96, 105, 37]; + accounts: [ + { + name: "rentReceiver"; + writable: true; + }, + { + name: "position"; + writable: true; + }, + { + name: "owner"; + signer: true; + relations: ["position"]; + }, + { + 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" + name: "program"; } - ], - "args": [ + ]; + args: [ { - "name": "amountIn", - "type": "u64" + name: "lengthToRemove"; + type: "u16"; }, { - "name": "minAmountOut", - "type": "u64" + name: "side"; + type: "u8"; } - ] + ]; }, { - "name": "swapExactOut", - "discriminator": [ - 250, - 73, - 101, - 33, - 38, - 207, - 75, - 184 - ], - "accounts": [ + name: "forIdlTypeGenerationDoNotCall"; + discriminator: [180, 105, 69, 80, 95, 50, 73, 108]; + accounts: [ { - "name": "lbPair", - "writable": true - }, + name: "dummyZcAccount"; + } + ]; + args: [ + { + name: "ix"; + type: { + defined: { + name: "dummyIx"; + }; + }; + } + ]; + }, + { + name: "fundReward"; + discriminator: [188, 50, 249, 165, 93, 151, 38, 63]; + accounts: [ { - "name": "binArrayBitmapExtension", - "optional": true + name: "lbPair"; + writable: true; + relations: ["binArray"]; }, { - "name": "reserveX", - "writable": true + name: "rewardVault"; + writable: true; }, { - "name": "reserveY", - "writable": true + name: "rewardMint"; }, { - "name": "userTokenIn", - "writable": true + name: "funderTokenAccount"; + writable: true; }, { - "name": "userTokenOut", - "writable": true + name: "funder"; + signer: true; }, { - "name": "tokenXMint" + name: "binArray"; + writable: true; }, { - "name": "tokenYMint" + name: "tokenProgram"; }, { - "name": "oracle", - "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": "hostFeeIn", - "writable": true, - "optional": true - }, + name: "program"; + } + ]; + args: [ { - "name": "user", - "signer": true + name: "rewardIndex"; + type: "u64"; }, { - "name": "tokenXProgram" + name: "amount"; + type: "u64"; }, { - "name": "tokenYProgram" + name: "carryForward"; + type: "bool"; }, { - "name": "eventAuthority" + name: "remainingAccountsInfo"; + type: { + defined: { + name: "remainingAccountsInfo"; + }; + }; + } + ]; + }, + { + name: "goToABin"; + discriminator: [146, 72, 174, 224, 40, 253, 84, 174]; + accounts: [ + { + name: "lbPair"; + writable: true; + relations: ["binArrayBitmapExtension", "fromBinArray", "toBinArray"]; + }, + { + name: "binArrayBitmapExtension"; + optional: true; + }, + { + name: "fromBinArray"; + optional: true; + }, + { + name: "toBinArray"; + 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" + name: "program"; } - ], - "args": [ + ]; + args: [ { - "name": "maxInAmount", - "type": "u64" + name: "binId"; + type: "i32"; + } + ]; + }, + { + name: "increaseOracleLength"; + discriminator: [190, 61, 125, 87, 103, 79, 158, 173]; + accounts: [ + { + name: "oracle"; + writable: true; + }, + { + name: "funder"; + 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": "outAmount", - "type": "u64" + name: "program"; + } + ]; + args: [ + { + name: "lengthToAdd"; + type: "u64"; } - ] + ]; }, { - "name": "swapWithPriceImpact", - "discriminator": [ - 56, - 173, - 230, - 208, - 173, - 228, - 156, - 205 - ], - "accounts": [ + name: "increasePositionLength"; + discriminator: [80, 83, 117, 211, 66, 13, 33, 149]; + accounts: [ { - "name": "lbPair", - "writable": true + name: "funder"; + writable: true; + signer: true; }, { - "name": "binArrayBitmapExtension", - "optional": true + name: "lbPair"; + relations: ["position"]; }, { - "name": "reserveX", - "writable": true + name: "position"; + writable: true; }, { - "name": "reserveY", - "writable": true + name: "owner"; + signer: true; + relations: ["position"]; }, { - "name": "userTokenIn", - "writable": true + name: "systemProgram"; + address: "11111111111111111111111111111111"; }, { - "name": "userTokenOut", - "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": "tokenXMint" - }, + name: "program"; + } + ]; + args: [ { - "name": "tokenYMint" + name: "lengthToAdd"; + type: "u16"; }, { - "name": "oracle", - "writable": true + name: "side"; + type: "u8"; + } + ]; + }, + { + name: "increasePositionLength2"; + discriminator: [255, 210, 204, 71, 115, 137, 225, 113]; + accounts: [ + { + name: "funder"; + writable: true; + signer: true; }, { - "name": "hostFeeIn", - "writable": true, - "optional": true + name: "lbPair"; + relations: ["position"]; }, { - "name": "user", - "signer": true + name: "position"; + writable: true; }, { - "name": "tokenXProgram" + name: "owner"; + signer: true; + relations: ["position"]; }, { - "name": "tokenYProgram" + name: "systemProgram"; + address: "11111111111111111111111111111111"; }, { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [ + ]; + args: [ { - "name": "amountIn", - "type": "u64" + name: "minimumUpperBinId"; + type: "i32"; + } + ]; + }, + { + name: "initializeBinArray"; + discriminator: [35, 86, 19, 185, 78, 212, 75, 211]; + accounts: [ + { + name: "lbPair"; + }, + { + name: "binArray"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [98, 105, 110, 95, 97, 114, 114, 97, 121]; + }, + { + kind: "account"; + path: "lbPair"; + }, + { + kind: "arg"; + path: "index"; + } + ]; + }; }, { - "name": "activeId", - "type": { - "option": "i32" - } + name: "funder"; + writable: true; + signer: true; }, { - "name": "maxPriceImpactBps", - "type": "u16" + name: "systemProgram"; + address: "11111111111111111111111111111111"; } - ] + ]; + args: [ + { + name: "index"; + type: "i64"; + } + ]; }, { - "name": "withdrawProtocolFee", - "discriminator": [ - 158, - 201, - 158, - 189, - 33, - 93, - 162, - 103 - ], - "accounts": [ + name: "initializeBinArrayBitmapExtension"; + discriminator: [47, 157, 226, 180, 12, 240, 33, 71]; + accounts: [ { - "name": "lbPair", - "writable": true + name: "lbPair"; }, { - "name": "reserveX", - "writable": true + name: "binArrayBitmapExtension"; + docs: [ + "Initialize an account to store if a bin array is initialized." + ]; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [98, 105, 116, 109, 97, 112]; + }, + { + kind: "account"; + path: "lbPair"; + } + ]; + }; }, { - "name": "reserveY", - "writable": true + name: "funder"; + writable: true; + signer: true; }, { - "name": "tokenXMint" + name: "systemProgram"; + address: "11111111111111111111111111111111"; }, { - "name": "tokenYMint" + name: "rent"; + address: "SysvarRent111111111111111111111111111111111"; + } + ]; + args: []; + }, + { + name: "initializeCustomizablePermissionlessLbPair"; + discriminator: [46, 39, 41, 135, 111, 183, 200, 64]; + accounts: [ + { + name: "lbPair"; + writable: true; + }, + { + name: "binArrayBitmapExtension"; + writable: true; + optional: true; + pda: { + seeds: [ + { + kind: "const"; + value: [98, 105, 116, 109, 97, 112]; + }, + { + kind: "account"; + path: "lbPair"; + } + ]; + }; }, { - "name": "receiverTokenX", - "writable": true + name: "tokenMintX"; }, { - "name": "receiverTokenY", - "writable": true + name: "tokenMintY"; }, { - "name": "claimFeeOperator" + name: "reserveX"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "lbPair"; + }, + { + kind: "account"; + path: "tokenMintX"; + } + ]; + }; + }, + { + name: "reserveY"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "lbPair"; + }, + { + kind: "account"; + path: "tokenMintY"; + } + ]; + }; + }, + { + name: "oracle"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [111, 114, 97, 99, 108, 101]; + }, + { + kind: "account"; + path: "lbPair"; + } + ]; + }; }, { - "name": "operator", - "docs": [ - "operator" - ], - "signer": true + name: "userTokenX"; }, { - "name": "tokenXProgram" + name: "funder"; + writable: true; + signer: true; }, { - "name": "tokenYProgram" + name: "tokenProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "memoProgram" - } - ], - "args": [ + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, { - "name": "amountX", - "type": "u64" + name: "userTokenY"; }, { - "name": "amountY", - "type": "u64" + 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": "remainingAccountsInfo", - "type": { - "defined": { - "name": "remainingAccountsInfo" - } - } + name: "program"; + } + ]; + args: [ + { + name: "params"; + type: { + defined: { + name: "customizableParams"; + }; + }; } - ] + ]; }, { - "name": "initializeReward", - "discriminator": [ - 95, - 135, - 192, - 196, - 242, - 129, - 230, - 68 - ], - "accounts": [ + name: "initializeCustomizablePermissionlessLbPair2"; + discriminator: [243, 73, 129, 126, 51, 19, 241, 107]; + accounts: [ + { + name: "lbPair"; + writable: true; + }, { - "name": "lbPair", - "writable": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; + pda: { + seeds: [ + { + kind: "const"; + value: [98, 105, 116, 109, 97, 112]; + }, + { + kind: "account"; + path: "lbPair"; + } + ]; + }; + }, + { + name: "tokenMintX"; }, { - "name": "rewardVault", - "writable": true + name: "tokenMintY"; }, { - "name": "rewardMint" + name: "reserveX"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "lbPair"; + }, + { + kind: "account"; + path: "tokenMintX"; + } + ]; + }; + }, + { + name: "reserveY"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "lbPair"; + }, + { + kind: "account"; + path: "tokenMintY"; + } + ]; + }; + }, + { + name: "oracle"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [111, 114, 97, 99, 108, 101]; + }, + { + kind: "account"; + path: "lbPair"; + } + ]; + }; }, { - "name": "tokenBadge", - "optional": true + name: "userTokenX"; }, { - "name": "admin", - "writable": true, - "signer": true + name: "funder"; + writable: true; + signer: true; }, { - "name": "tokenProgram" + name: "tokenBadgeX"; + optional: true; }, { - "name": "systemProgram" + name: "tokenBadgeY"; + optional: true; }, { - "name": "rent" + name: "tokenProgramX"; }, { - "name": "eventAuthority" + name: "tokenProgramY"; }, { - "name": "program" - } - ], - "args": [ + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, { - "name": "rewardIndex", - "type": "u64" + name: "userTokenY"; }, { - "name": "rewardDuration", - "type": "u64" + 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": "funder", - "type": "pubkey" + name: "program"; + } + ]; + args: [ + { + name: "params"; + type: { + defined: { + name: "customizableParams"; + }; + }; } - ] + ]; }, { - "name": "fundReward", - "discriminator": [ - 188, - 50, - 249, - 165, - 93, - 151, - 38, - 63 - ], - "accounts": [ + name: "initializeLbPair"; + discriminator: [45, 154, 237, 210, 221, 15, 166, 92]; + accounts: [ { - "name": "lbPair", - "writable": true + name: "lbPair"; + writable: true; }, { - "name": "rewardVault", - "writable": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; + pda: { + seeds: [ + { + kind: "const"; + value: [98, 105, 116, 109, 97, 112]; + }, + { + kind: "account"; + path: "lbPair"; + } + ]; + }; }, { - "name": "rewardMint" + name: "tokenMintX"; }, { - "name": "funderTokenAccount", - "writable": true + name: "tokenMintY"; }, { - "name": "funder", - "signer": true + name: "reserveX"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "lbPair"; + }, + { + kind: "account"; + path: "tokenMintX"; + } + ]; + }; + }, + { + name: "reserveY"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "lbPair"; + }, + { + kind: "account"; + path: "tokenMintY"; + } + ]; + }; + }, + { + name: "oracle"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [111, 114, 97, 99, 108, 101]; + }, + { + kind: "account"; + path: "lbPair"; + } + ]; + }; }, { - "name": "binArray", - "writable": true + name: "presetParameter"; }, { - "name": "tokenProgram" + name: "funder"; + writable: true; + signer: true; }, { - "name": "eventAuthority" + name: "tokenProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "program" - } - ], - "args": [ + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, { - "name": "rewardIndex", - "type": "u64" + name: "rent"; + address: "SysvarRent111111111111111111111111111111111"; }, { - "name": "amount", - "type": "u64" + 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": "carryForward", - "type": "bool" + name: "program"; + } + ]; + args: [ + { + name: "activeId"; + type: "i32"; }, { - "name": "remainingAccountsInfo", - "type": { - "defined": { - "name": "remainingAccountsInfo" - } - } + name: "binStep"; + type: "u16"; } - ] + ]; }, { - "name": "updateRewardFunder", - "discriminator": [ - 211, - 28, - 48, - 32, - 215, - 160, - 35, - 23 - ], - "accounts": [ + name: "initializeLbPair2"; + discriminator: [73, 59, 36, 120, 237, 83, 108, 198]; + accounts: [ { - "name": "lbPair", - "writable": true + name: "lbPair"; + writable: true; }, { - "name": "admin", - "signer": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; + pda: { + seeds: [ + { + kind: "const"; + value: [98, 105, 116, 109, 97, 112]; + }, + { + kind: "account"; + path: "lbPair"; + } + ]; + }; }, { - "name": "eventAuthority" + name: "tokenMintX"; }, { - "name": "program" - } - ], - "args": [ + name: "tokenMintY"; + }, { - "name": "rewardIndex", - "type": "u64" + name: "reserveX"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "lbPair"; + }, + { + kind: "account"; + path: "tokenMintX"; + } + ]; + }; + }, + { + name: "reserveY"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "lbPair"; + }, + { + kind: "account"; + path: "tokenMintY"; + } + ]; + }; + }, + { + name: "oracle"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [111, 114, 97, 99, 108, 101]; + }, + { + kind: "account"; + path: "lbPair"; + } + ]; + }; }, { - "name": "newFunder", - "type": "pubkey" - } - ] - }, - { - "name": "updateRewardDuration", - "discriminator": [ - 138, - 174, - 196, - 169, - 213, - 235, - 254, - 107 - ], - "accounts": [ + name: "presetParameter"; + }, { - "name": "lbPair", - "writable": true + name: "funder"; + writable: true; + signer: true; }, { - "name": "admin", - "signer": true + name: "tokenBadgeX"; + optional: true; }, { - "name": "binArray", - "writable": true + name: "tokenBadgeY"; + optional: true; }, { - "name": "eventAuthority" + name: "tokenProgramX"; }, { - "name": "program" - } - ], - "args": [ + name: "tokenProgramY"; + }, { - "name": "rewardIndex", - "type": "u64" + name: "systemProgram"; + address: "11111111111111111111111111111111"; }, { - "name": "newDuration", - "type": "u64" + 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: "initializeLbPair2Params"; + }; + }; } - ] + ]; }, { - "name": "claimReward", - "discriminator": [ - 149, - 95, - 181, - 242, - 94, - 90, - 158, - 162 - ], - "accounts": [ + name: "initializePermissionLbPair"; + discriminator: [108, 102, 213, 85, 251, 3, 53, 21]; + accounts: [ { - "name": "lbPair", - "writable": true + name: "base"; + signer: true; }, { - "name": "position", - "writable": true + name: "lbPair"; + writable: true; }, { - "name": "binArrayLower", - "writable": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; + pda: { + seeds: [ + { + kind: "const"; + value: [98, 105, 116, 109, 97, 112]; + }, + { + kind: "account"; + path: "lbPair"; + } + ]; + }; }, { - "name": "binArrayUpper", - "writable": true + name: "tokenMintX"; }, { - "name": "sender", - "signer": true + name: "tokenMintY"; }, { - "name": "rewardVault", - "writable": true + name: "reserveX"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "lbPair"; + }, + { + kind: "account"; + path: "tokenMintX"; + } + ]; + }; + }, + { + name: "reserveY"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "lbPair"; + }, + { + kind: "account"; + path: "tokenMintY"; + } + ]; + }; + }, + { + name: "oracle"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [111, 114, 97, 99, 108, 101]; + }, + { + kind: "account"; + path: "lbPair"; + } + ]; + }; }, { - "name": "rewardMint" + name: "admin"; + writable: true; + signer: true; }, { - "name": "userTokenAccount", - "writable": true + name: "tokenBadgeX"; + optional: true; }, { - "name": "tokenProgram" + name: "tokenBadgeY"; + optional: true; }, { - "name": "eventAuthority" + name: "tokenProgramX"; }, { - "name": "program" - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u64" - } - ] - }, - { - "name": "claimFee", - "discriminator": [ - 169, - 32, - 79, - 137, - 136, - 232, - 70, - 137 - ], - "accounts": [ - { - "name": "lbPair", - "writable": true + name: "tokenProgramY"; }, { - "name": "position", - "writable": true + name: "systemProgram"; + address: "11111111111111111111111111111111"; }, { - "name": "binArrayLower", - "writable": true + name: "rent"; + address: "SysvarRent111111111111111111111111111111111"; }, { - "name": "binArrayUpper", - "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": "sender", - "signer": true - }, + name: "program"; + } + ]; + args: [ + { + name: "ixData"; + type: { + defined: { + name: "initPermissionPairIx"; + }; + }; + } + ]; + }, + { + name: "initializePosition"; + discriminator: [219, 192, 234, 71, 190, 191, 102, 80]; + accounts: [ { - "name": "reserveX", - "writable": true + name: "payer"; + writable: true; + signer: true; }, { - "name": "reserveY", - "writable": true + name: "position"; + writable: true; + signer: true; }, { - "name": "userTokenX", - "writable": true + name: "lbPair"; }, { - "name": "userTokenY", - "writable": true + name: "owner"; + signer: true; }, { - "name": "tokenXMint" + name: "systemProgram"; + address: "11111111111111111111111111111111"; }, { - "name": "tokenYMint" + name: "rent"; + address: "SysvarRent111111111111111111111111111111111"; }, { - "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": "eventAuthority" + name: "program"; + } + ]; + args: [ + { + name: "lowerBinId"; + type: "i32"; }, { - "name": "program" + name: "width"; + type: "i32"; } - ], - "args": [] + ]; }, { - "name": "closePosition", - "discriminator": [ - 123, - 134, - 81, - 0, - 49, - 68, - 98, - 98 - ], - "accounts": [ + name: "initializePosition2"; + discriminator: [143, 19, 242, 145, 213, 15, 104, 115]; + accounts: [ { - "name": "position", - "writable": true + name: "payer"; + writable: true; + signer: true; }, { - "name": "lbPair", - "writable": true + name: "position"; + writable: true; + signer: true; }, { - "name": "binArrayLower", - "writable": true + name: "lbPair"; }, { - "name": "binArrayUpper", - "writable": true + name: "owner"; + signer: true; }, { - "name": "sender", - "signer": true + name: "systemProgram"; + address: "11111111111111111111111111111111"; }, { - "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": "eventAuthority" + name: "program"; + } + ]; + args: [ + { + name: "lowerBinId"; + type: "i32"; }, { - "name": "program" + name: "width"; + type: "i32"; } - ], - "args": [] - }, - { - "name": "updateBaseFeeParameters", - "discriminator": [ - 75, - 168, - 223, - 161, - 16, - 195, - 3, - 47 - ], - "accounts": [ + ]; + }, + { + name: "initializePositionByOperator"; + discriminator: [251, 189, 190, 244, 117, 254, 35, 148]; + accounts: [ + { + name: "payer"; + writable: true; + signer: true; + }, + { + name: "base"; + signer: true; + }, + { + name: "position"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [112, 111, 115, 105, 116, 105, 111, 110]; + }, + { + kind: "account"; + path: "lbPair"; + }, + { + kind: "account"; + path: "base"; + }, + { + kind: "arg"; + path: "lowerBinId"; + }, + { + kind: "arg"; + path: "width"; + } + ]; + }; + }, { - "name": "lbPair", - "writable": true + name: "lbPair"; }, { - "name": "admin", - "signer": true + name: "owner"; }, { - "name": "eventAuthority" + name: "operator"; + docs: ["operator"]; + signer: true; }, { - "name": "program" - } - ], - "args": [ - { - "name": "feeParameter", - "type": { - "defined": { - "name": "baseFeeParameter" - } - } - } - ] - }, - { - "name": "updateDynamicFeeParameters", - "discriminator": [ - 92, - 161, - 46, - 246, - 255, - 189, - 22, - 22 - ], - "accounts": [ + name: "operatorTokenX"; + }, { - "name": "lbPair", - "writable": true + name: "ownerTokenX"; }, { - "name": "admin", - "signer": true + name: "systemProgram"; + address: "11111111111111111111111111111111"; }, { - "name": "eventAuthority" + 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": "feeParameter", - "type": { - "defined": { - "name": "dynamicFeeParameter" - } - } + name: "program"; } - ] - }, - { - "name": "increaseOracleLength", - "discriminator": [ - 190, - 61, - 125, - 87, - 103, - 79, - 158, - 173 - ], - "accounts": [ + ]; + args: [ { - "name": "oracle", - "writable": true + name: "lowerBinId"; + type: "i32"; }, { - "name": "funder", - "writable": true, - "signer": true + name: "width"; + type: "i32"; }, { - "name": "systemProgram" + name: "feeOwner"; + type: "pubkey"; }, { - "name": "eventAuthority" + name: "lockReleasePoint"; + type: "u64"; + } + ]; + }, + { + name: "initializePositionPda"; + discriminator: [46, 82, 125, 146, 85, 141, 228, 153]; + accounts: [ + { + name: "payer"; + writable: true; + signer: true; + }, + { + name: "base"; + signer: true; + }, + { + name: "position"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [112, 111, 115, 105, 116, 105, 111, 110]; + }, + { + kind: "account"; + path: "lbPair"; + }, + { + kind: "account"; + path: "base"; + }, + { + kind: "arg"; + path: "lowerBinId"; + }, + { + kind: "arg"; + path: "width"; + } + ]; + }; + }, + { + name: "lbPair"; + }, + { + name: "owner"; + docs: ["owner"]; + signer: true; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + { + name: "rent"; + address: "SysvarRent111111111111111111111111111111111"; + }, + { + 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" + name: "program"; } - ], - "args": [ + ]; + args: [ { - "name": "lengthToAdd", - "type": "u64" - } - ] - }, - { - "name": "initializePresetParameter", - "discriminator": [ - 66, - 188, - 71, - 211, - 98, - 109, - 14, - 186 - ], - "accounts": [ + name: "lowerBinId"; + type: "i32"; + }, { - "name": "presetParameter", - "writable": true + name: "width"; + type: "i32"; + } + ]; + }, + { + name: "initializePresetParameter"; + discriminator: [66, 188, 71, 211, 98, 109, 14, 186]; + accounts: [ + { + name: "presetParameter"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 112, + 114, + 101, + 115, + 101, + 116, + 95, + 112, + 97, + 114, + 97, + 109, + 101, + 116, + 101, + 114 + ]; + }, + { + kind: "arg"; + path: "ix.bin_step"; + }, + { + kind: "arg"; + path: "ix.base_factor"; + } + ]; + }; }, { - "name": "admin", - "writable": true, - "signer": true + name: "admin"; + writable: true; + signer: true; }, { - "name": "systemProgram" + name: "systemProgram"; + address: "11111111111111111111111111111111"; }, { - "name": "rent" + name: "rent"; + address: "SysvarRent111111111111111111111111111111111"; } - ], - "args": [ - { - "name": "ix", - "type": { - "defined": { - "name": "initPresetParametersIx" - } - } + ]; + args: [ + { + name: "ix"; + type: { + defined: { + name: "initPresetParametersIx"; + }; + }; } - ] - }, - { - "name": "closePresetParameter", - "discriminator": [ - 4, - 148, - 145, - 100, - 134, - 26, - 181, - 61 - ], - "accounts": [ - { - "name": "presetParameter", - "writable": true + ]; + }, + { + name: "initializePresetParameter2"; + discriminator: [184, 7, 240, 171, 103, 47, 183, 121]; + accounts: [ + { + name: "presetParameter"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 112, + 114, + 101, + 115, + 101, + 116, + 95, + 112, + 97, + 114, + 97, + 109, + 101, + 116, + 101, + 114, + 50 + ]; + }, + { + kind: "arg"; + path: "ix.index"; + } + ]; + }; }, { - "name": "admin", - "writable": true, - "signer": true + name: "admin"; + writable: true; + signer: true; }, { - "name": "rentReceiver", - "writable": true + name: "systemProgram"; + address: "11111111111111111111111111111111"; + } + ]; + args: [ + { + name: "ix"; + type: { + defined: { + name: "initPresetParameters2Ix"; + }; + }; } - ], - "args": [] + ]; }, { - "name": "closePresetParameter2", - "discriminator": [ - 39, - 25, - 95, - 107, - 116, - 17, - 115, - 28 - ], - "accounts": [ + name: "initializeReward"; + discriminator: [95, 135, 192, 196, 242, 129, 230, 68]; + accounts: [ { - "name": "presetParameter", - "writable": true + name: "lbPair"; + writable: true; }, { - "name": "admin", - "writable": true, - "signer": true + name: "rewardVault"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "lbPair"; + }, + { + kind: "arg"; + path: "rewardIndex"; + } + ]; + }; }, { - "name": "rentReceiver", - "writable": true - } - ], - "args": [] - }, - { - "name": "removeAllLiquidity", - "discriminator": [ - 10, - 51, - 61, - 35, - 112, - 105, - 24, - 85 - ], - "accounts": [ - { - "name": "position", - "writable": true + name: "rewardMint"; }, { - "name": "lbPair", - "writable": true + name: "tokenBadge"; + optional: true; }, { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "admin"; + writable: true; + signer: true; }, { - "name": "userTokenX", - "writable": true + name: "tokenProgram"; }, { - "name": "userTokenY", - "writable": true + name: "systemProgram"; + address: "11111111111111111111111111111111"; }, { - "name": "reserveX", - "writable": true + name: "rent"; + address: "SysvarRent111111111111111111111111111111111"; }, { - "name": "reserveY", - "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": "tokenXMint" - }, + name: "program"; + } + ]; + args: [ { - "name": "tokenYMint" + name: "rewardIndex"; + type: "u64"; }, { - "name": "binArrayLower", - "writable": true + name: "rewardDuration"; + type: "u64"; }, { - "name": "binArrayUpper", - "writable": true - }, - { - "name": "sender", - "signer": true - }, + name: "funder"; + type: "pubkey"; + } + ]; + }, + { + name: "initializeTokenBadge"; + discriminator: [253, 77, 205, 95, 27, 224, 89, 223]; + accounts: [ { - "name": "tokenXProgram" + name: "tokenMint"; }, { - "name": "tokenYProgram" + 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": "eventAuthority" + name: "admin"; + writable: true; + signer: true; }, { - "name": "program" + name: "systemProgram"; + address: "11111111111111111111111111111111"; } - ], - "args": [] + ]; + args: []; }, { - "name": "setPairStatus", - "discriminator": [ - 67, - 248, - 231, - 137, - 154, - 149, - 217, - 174 - ], - "accounts": [ - { - "name": "lbPair", - "writable": true - }, - { - "name": "admin", - "signer": true - } - ], - "args": [ + name: "migrateBinArray"; + discriminator: [17, 23, 159, 211, 101, 184, 41, 241]; + accounts: [ { - "name": "status", - "type": "u8" + name: "lbPair"; } - ] + ]; + args: []; }, { - "name": "migratePosition", - "discriminator": [ - 15, - 132, - 59, - 50, - 199, - 6, - 251, - 46 - ], - "accounts": [ + name: "migratePosition"; + discriminator: [15, 132, 59, 50, 199, 6, 251, 46]; + accounts: [ { - "name": "positionV2", - "writable": true, - "signer": true + name: "positionV2"; + writable: true; + signer: true; }, { - "name": "positionV1", - "writable": true + name: "positionV1"; + writable: true; }, { - "name": "lbPair" + name: "lbPair"; + relations: ["positionV1", "binArrayLower", "binArrayUpper"]; }, { - "name": "binArrayLower", - "writable": true + name: "binArrayLower"; + writable: true; }, { - "name": "binArrayUpper", - "writable": true + name: "binArrayUpper"; + writable: true; }, { - "name": "owner", - "writable": true, - "signer": true + name: "owner"; + writable: true; + signer: true; + relations: ["positionV1"]; }, { - "name": "systemProgram" + name: "systemProgram"; + address: "11111111111111111111111111111111"; }, { - "name": "rentReceiver", - "writable": true + name: "rentReceiver"; + writable: true; }, { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [] - }, - { - "name": "migrateBinArray", - "discriminator": [ - 17, - 23, - 159, - 211, - 101, - 184, - 41, - 241 - ], - "accounts": [ - { - "name": "lbPair" - } - ], - "args": [] + ]; + args: []; }, { - "name": "updateFeesAndRewards", - "discriminator": [ - 154, - 230, - 250, - 13, - 236, - 209, - 75, - 223 - ], - "accounts": [ + name: "rebalanceLiquidity"; + discriminator: [92, 4, 176, 193, 119, 185, 83, 9]; + accounts: [ { - "name": "position", - "writable": true + name: "position"; + writable: true; }, { - "name": "lbPair", - "writable": true + name: "lbPair"; + writable: true; + relations: ["position", "binArrayBitmapExtension"]; }, { - "name": "binArrayLower", - "writable": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "binArrayUpper", - "writable": true + name: "userTokenX"; + writable: true; }, { - "name": "owner", - "signer": true - } - ], - "args": [] - }, - { - "name": "withdrawIneligibleReward", - "discriminator": [ - 148, - 206, - 42, - 195, - 247, - 49, - 103, - 8 - ], - "accounts": [ - { - "name": "lbPair", - "writable": true + name: "userTokenY"; + writable: true; }, { - "name": "rewardVault", - "writable": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "rewardMint" + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "funderTokenAccount", - "writable": true + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "funder", - "signer": true + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "binArray", - "writable": true + name: "owner"; + signer: true; + relations: ["position"]; }, { - "name": "tokenProgram" + name: "rentPayer"; + writable: true; + signer: true; }, { - "name": "memoProgram" + name: "tokenXProgram"; }, { - "name": "eventAuthority" + name: "tokenYProgram"; }, { - "name": "program" - } - ], - "args": [ - { - "name": "rewardIndex", - "type": "u64" + name: "memoProgram"; + address: "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"; }, { - "name": "remainingAccountsInfo", - "type": { - "defined": { - "name": "remainingAccountsInfo" - } - } - } - ] - }, - { - "name": "setActivationPoint", - "discriminator": [ - 91, - 249, - 15, - 165, - 26, - 129, - 254, - 125 - ], - "accounts": [ + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, { - "name": "lbPair", - "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": "admin", - "writable": true, - "signer": true + name: "program"; } - ], - "args": [ - { - "name": "activationPoint", - "type": "u64" + ]; + args: [ + { + name: "params"; + type: { + defined: { + name: "rebalanceLiquidityParams"; + }; + }; + }, + { + name: "remainingAccountsInfo"; + type: { + defined: { + name: "remainingAccountsInfo"; + }; + }; } - ] + ]; }, { - "name": "removeLiquidityByRange", - "discriminator": [ - 26, - 82, - 102, - 152, - 240, - 74, - 105, - 26 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, + name: "removeAllLiquidity"; + discriminator: [10, 51, 61, 35, 112, 105, 24, 85]; + accounts: [ { - "name": "lbPair", - "writable": true + name: "position"; + writable: true; }, { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "lbPair"; + writable: true; + relations: [ + "position", + "binArrayBitmapExtension", + "binArrayLower", + "binArrayUpper" + ]; }, { - "name": "userTokenX", - "writable": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "userTokenY", - "writable": true + name: "userTokenX"; + writable: true; }, { - "name": "reserveX", - "writable": true + name: "userTokenY"; + writable: true; }, { - "name": "reserveY", - "writable": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "tokenXMint" + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "tokenYMint" + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "binArrayLower", - "writable": true + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "binArrayUpper", - "writable": true + name: "binArrayLower"; + writable: true; }, { - "name": "sender", - "signer": true + name: "binArrayUpper"; + writable: true; }, { - "name": "tokenXProgram" + name: "sender"; + signer: true; }, { - "name": "tokenYProgram" + name: "tokenXProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "fromBinId", - "type": "i32" + name: "tokenYProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "toBinId", - "type": "i32" + 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": "bpsToRemove", - "type": "u16" + name: "program"; } - ] + ]; + args: []; }, { - "name": "addLiquidityOneSidePrecise", - "discriminator": [ - 161, - 194, - 103, - 84, - 171, - 71, - 250, - 154 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, + name: "removeLiquidity"; + discriminator: [80, 85, 209, 72, 24, 206, 177, 108]; + accounts: [ { - "name": "lbPair", - "writable": true + name: "position"; + writable: true; }, { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "lbPair"; + writable: true; + relations: [ + "position", + "binArrayBitmapExtension", + "binArrayLower", + "binArrayUpper" + ]; }, { - "name": "userToken", - "writable": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "reserve", - "writable": true + name: "userTokenX"; + writable: true; }, { - "name": "tokenMint" + name: "userTokenY"; + writable: true; }, { - "name": "binArrayLower", - "writable": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "binArrayUpper", - "writable": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "sender", - "signer": true + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "tokenProgram" + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "eventAuthority" + name: "binArrayLower"; + writable: true; }, { - "name": "program" - } - ], - "args": [ - { - "name": "parameter", - "type": { - "defined": { - "name": "addLiquiditySingleSidePreciseParameter" - } - } - } - ] - }, - { - "name": "goToABin", - "discriminator": [ - 146, - 72, - 174, - 224, - 40, - 253, - 84, - 174 - ], - "accounts": [ - { - "name": "lbPair", - "writable": true + name: "binArrayUpper"; + writable: true; }, { - "name": "binArrayBitmapExtension", - "optional": true + name: "sender"; + signer: true; }, { - "name": "fromBinArray", - "optional": true + name: "tokenXProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "toBinArray", - "optional": true + name: "tokenYProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [ - { - "name": "binId", - "type": "i32" + ]; + args: [ + { + name: "binLiquidityRemoval"; + type: { + vec: { + defined: { + name: "binLiquidityReduction"; + }; + }; + }; } - ] + ]; }, { - "name": "setPreActivationDuration", - "discriminator": [ - 165, - 61, - 201, - 244, - 130, - 159, - 22, - 100 - ], - "accounts": [ + name: "removeLiquidity2"; + discriminator: [230, 215, 82, 127, 241, 101, 227, 146]; + accounts: [ { - "name": "lbPair", - "writable": true + name: "position"; + writable: true; }, { - "name": "creator", - "signer": true - } - ], - "args": [ - { - "name": "preActivationDuration", - "type": "u64" - } - ] - }, - { - "name": "setPreActivationSwapAddress", - "discriminator": [ - 57, - 139, - 47, - 123, - 216, - 80, - 223, - 10 - ], - "accounts": [ - { - "name": "lbPair", - "writable": true + name: "lbPair"; + writable: true; + relations: ["position", "binArrayBitmapExtension"]; }, { - "name": "creator", - "signer": true - } - ], - "args": [ - { - "name": "preActivationSwapAddress", - "type": "pubkey" - } - ] - }, - { - "name": "setPairStatusPermissionless", - "discriminator": [ - 78, - 59, - 152, - 211, - 70, - 183, - 46, - 208 - ], - "accounts": [ - { - "name": "lbPair", - "writable": true + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "creator", - "signer": true - } - ], - "args": [ - { - "name": "status", - "type": "u8" - } - ] - }, - { - "name": "initializeTokenBadge", - "discriminator": [ - 253, - 77, - 205, - 95, - 27, - 224, - 89, - 223 - ], - "accounts": [ - { - "name": "tokenMint" + name: "userTokenX"; + writable: true; }, { - "name": "tokenBadge", - "writable": true + name: "userTokenY"; + writable: true; }, { - "name": "admin", - "writable": true, - "signer": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "systemProgram" - } - ], - "args": [] - }, - { - "name": "createClaimProtocolFeeOperator", - "discriminator": [ - 51, - 19, - 150, - 252, - 105, - 157, - 48, - 91 - ], - "accounts": [ - { - "name": "claimFeeOperator", - "writable": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "operator" + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "admin", - "writable": true, - "signer": true + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "systemProgram" - } - ], - "args": [] - }, - { - "name": "closeClaimProtocolFeeOperator", - "discriminator": [ - 8, - 41, - 87, - 35, - 80, - 48, - 121, - 26 - ], - "accounts": [ - { - "name": "claimFeeOperator", - "writable": true + name: "sender"; + signer: true; }, { - "name": "rentReceiver", - "writable": true + name: "tokenXProgram"; }, { - "name": "admin", - "signer": true - } - ], - "args": [] - }, - { - "name": "initializePresetParameter2", - "discriminator": [ - 184, - 7, - 240, - 171, - 103, - 47, - 183, - 121 - ], - "accounts": [ + name: "tokenYProgram"; + }, { - "name": "presetParameter", - "writable": true + name: "memoProgram"; + address: "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"; }, { - "name": "admin", - "writable": true, - "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": "systemProgram" + name: "program"; } - ], - "args": [ - { - "name": "ix", - "type": { - "defined": { - "name": "initPresetParameters2Ix" - } - } + ]; + args: [ + { + name: "binLiquidityRemoval"; + type: { + vec: { + defined: { + name: "binLiquidityReduction"; + }; + }; + }; + }, + { + name: "remainingAccountsInfo"; + type: { + defined: { + name: "remainingAccountsInfo"; + }; + }; } - ] + ]; }, { - "name": "initializeLbPair2", - "discriminator": [ - 73, - 59, - 36, - 120, - 237, - 83, - 108, - 198 - ], - "accounts": [ + name: "removeLiquidityByRange"; + discriminator: [26, 82, 102, 152, 240, 74, 105, 26]; + accounts: [ { - "name": "lbPair", - "writable": true + name: "position"; + writable: true; }, { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "lbPair"; + writable: true; + relations: [ + "position", + "binArrayBitmapExtension", + "binArrayLower", + "binArrayUpper" + ]; }, { - "name": "tokenMintX" + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "tokenMintY" + name: "userTokenX"; + writable: true; }, { - "name": "reserveX", - "writable": true + name: "userTokenY"; + writable: true; }, { - "name": "reserveY", - "writable": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "oracle", - "writable": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "presetParameter" + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "funder", - "writable": true, - "signer": true + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "tokenBadgeX", - "optional": true + name: "binArrayLower"; + writable: true; }, { - "name": "tokenBadgeY", - "optional": true + name: "binArrayUpper"; + writable: true; }, { - "name": "tokenProgramX" + name: "sender"; + signer: true; }, { - "name": "tokenProgramY" + name: "tokenXProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "systemProgram" + name: "tokenYProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "initializeLbPair2Params" - } - } - } - ] - }, - { - "name": "initializeCustomizablePermissionlessLbPair2", - "discriminator": [ - 243, - 73, - 129, - 126, - 51, - 19, - 241, - 107 - ], - "accounts": [ - { - "name": "lbPair", - "writable": true - }, - { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true - }, - { - "name": "tokenMintX" - }, - { - "name": "tokenMintY" - }, - { - "name": "reserveX", - "writable": true - }, - { - "name": "reserveY", - "writable": true - }, - { - "name": "oracle", - "writable": true - }, - { - "name": "userTokenX" - }, + ]; + args: [ { - "name": "funder", - "writable": true, - "signer": true + name: "fromBinId"; + type: "i32"; }, { - "name": "tokenBadgeX", - "optional": true + name: "toBinId"; + type: "i32"; }, { - "name": "tokenBadgeY", - "optional": true - }, + name: "bpsToRemove"; + type: "u16"; + } + ]; + }, + { + name: "removeLiquidityByRange2"; + discriminator: [204, 2, 195, 145, 53, 145, 145, 205]; + accounts: [ { - "name": "tokenProgramX" + name: "position"; + writable: true; }, { - "name": "tokenProgramY" + name: "lbPair"; + writable: true; + relations: ["position", "binArrayBitmapExtension"]; }, { - "name": "systemProgram" + name: "binArrayBitmapExtension"; + writable: true; + optional: true; }, { - "name": "userTokenY" + name: "userTokenX"; + writable: true; }, { - "name": "eventAuthority" + name: "userTokenY"; + writable: true; }, { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "customizableParams" - } - } - } - ] - }, - { - "name": "claimFee2", - "discriminator": [ - 112, - 191, - 101, - 171, - 28, - 144, - 127, - 187 - ], - "accounts": [ - { - "name": "lbPair", - "writable": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "position", - "writable": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "sender", - "signer": true + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "reserveX", - "writable": true + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "reserveY", - "writable": true + name: "sender"; + signer: true; }, { - "name": "userTokenX", - "writable": true + name: "tokenXProgram"; }, { - "name": "userTokenY", - "writable": true + name: "tokenYProgram"; }, { - "name": "tokenXMint" + name: "memoProgram"; + address: "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"; }, { - "name": "tokenYMint" + 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": "tokenProgramX" - }, + name: "program"; + } + ]; + args: [ { - "name": "tokenProgramY" + name: "fromBinId"; + type: "i32"; }, { - "name": "memoProgram" + name: "toBinId"; + type: "i32"; }, { - "name": "eventAuthority" + name: "bpsToRemove"; + type: "u16"; }, { - "name": "program" + name: "remainingAccountsInfo"; + type: { + defined: { + name: "remainingAccountsInfo"; + }; + }; } - ], - "args": [ + ]; + }, + { + name: "setActivationPoint"; + discriminator: [91, 249, 15, 165, 26, 129, 254, 125]; + accounts: [ { - "name": "minBinId", - "type": "i32" + name: "lbPair"; + writable: true; }, { - "name": "maxBinId", - "type": "i32" - }, + name: "admin"; + writable: true; + signer: true; + } + ]; + args: [ { - "name": "remainingAccountsInfo", - "type": { - "defined": { - "name": "remainingAccountsInfo" - } - } + name: "activationPoint"; + type: "u64"; } - ] + ]; }, { - "name": "claimReward2", - "discriminator": [ - 190, - 3, - 127, - 119, - 178, - 87, - 157, - 183 - ], - "accounts": [ - { - "name": "lbPair", - "writable": true - }, + name: "setPairStatus"; + discriminator: [67, 248, 231, 137, 154, 149, 217, 174]; + accounts: [ { - "name": "position", - "writable": true + name: "lbPair"; + writable: true; }, { - "name": "sender", - "signer": true - }, - { - "name": "rewardVault", - "writable": true - }, + name: "admin"; + signer: true; + } + ]; + args: [ { - "name": "rewardMint" - }, + name: "status"; + type: "u8"; + } + ]; + }, + { + name: "setPairStatusPermissionless"; + discriminator: [78, 59, 152, 211, 70, 183, 46, 208]; + accounts: [ { - "name": "userTokenAccount", - "writable": true + name: "lbPair"; + writable: true; }, { - "name": "tokenProgram" - }, + name: "creator"; + signer: true; + relations: ["lbPair"]; + } + ]; + args: [ { - "name": "memoProgram" - }, + name: "status"; + type: "u8"; + } + ]; + }, + { + name: "setPreActivationDuration"; + discriminator: [165, 61, 201, 244, 130, 159, 22, 100]; + accounts: [ { - "name": "eventAuthority" + name: "lbPair"; + writable: true; }, { - "name": "program" + name: "creator"; + signer: true; + relations: ["lbPair"]; } - ], - "args": [ + ]; + args: [ { - "name": "rewardIndex", - "type": "u64" - }, + name: "preActivationDuration"; + type: "u64"; + } + ]; + }, + { + name: "setPreActivationSwapAddress"; + discriminator: [57, 139, 47, 123, 216, 80, 223, 10]; + accounts: [ { - "name": "minBinId", - "type": "i32" + name: "lbPair"; + writable: true; }, { - "name": "maxBinId", - "type": "i32" - }, + name: "creator"; + signer: true; + relations: ["lbPair"]; + } + ]; + args: [ { - "name": "remainingAccountsInfo", - "type": { - "defined": { - "name": "remainingAccountsInfo" - } - } + name: "preActivationSwapAddress"; + type: "pubkey"; } - ] + ]; }, { - "name": "addLiquidity2", - "discriminator": [ - 228, - 162, - 78, - 28, - 70, - 219, - 116, - 115 - ], - "accounts": [ + name: "swap"; + discriminator: [248, 198, 158, 145, 225, 117, 135, 200]; + accounts: [ { - "name": "position", - "writable": true + name: "lbPair"; + writable: true; + relations: ["binArrayBitmapExtension"]; }, { - "name": "lbPair", - "writable": true + name: "binArrayBitmapExtension"; + optional: true; }, { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "userTokenX", - "writable": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "userTokenY", - "writable": true + name: "userTokenIn"; + writable: true; }, { - "name": "reserveX", - "writable": true + name: "userTokenOut"; + writable: true; }, { - "name": "reserveY", - "writable": true + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "tokenXMint" + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "tokenYMint" + name: "oracle"; + writable: true; + relations: ["lbPair"]; }, { - "name": "sender", - "signer": true + name: "hostFeeIn"; + writable: true; + optional: true; }, { - "name": "tokenXProgram" + name: "user"; + signer: true; }, { - "name": "tokenYProgram" + name: "tokenXProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "eventAuthority" + name: "tokenYProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "program" - } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": { - "name": "liquidityParameter" - } - } + 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": "remainingAccountsInfo", - "type": { - "defined": { - "name": "remainingAccountsInfo" - } - } + name: "program"; } - ] - }, - { - "name": "addLiquidityByStrategy2", - "discriminator": [ - 3, - 221, - 149, - 218, - 111, - 141, - 118, - 213 - ], - "accounts": [ - { - "name": "position", - "writable": true - }, - { - "name": "lbPair", - "writable": true - }, - { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true - }, - { - "name": "userTokenX", - "writable": true - }, + ]; + args: [ { - "name": "userTokenY", - "writable": true + name: "amountIn"; + type: "u64"; }, { - "name": "reserveX", - "writable": true - }, + name: "minAmountOut"; + type: "u64"; + } + ]; + }, + { + name: "swap2"; + discriminator: [65, 75, 63, 76, 235, 91, 91, 136]; + accounts: [ { - "name": "reserveY", - "writable": true + name: "lbPair"; + writable: true; + relations: ["binArrayBitmapExtension"]; }, { - "name": "tokenXMint" + name: "binArrayBitmapExtension"; + optional: true; }, { - "name": "tokenYMint" + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "sender", - "signer": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "tokenXProgram" + name: "userTokenIn"; + writable: true; }, { - "name": "tokenYProgram" + name: "userTokenOut"; + writable: true; }, { - "name": "eventAuthority" + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "program" - } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": { - "name": "liquidityParameterByStrategy" - } - } + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "remainingAccountsInfo", - "type": { - "defined": { - "name": "remainingAccountsInfo" - } - } - } - ] - }, - { - "name": "addLiquidityOneSidePrecise2", - "discriminator": [ - 33, - 51, - 163, - 201, - 117, - 98, - 125, - 231 - ], - "accounts": [ - { - "name": "position", - "writable": true + name: "oracle"; + writable: true; + relations: ["lbPair"]; }, { - "name": "lbPair", - "writable": true + name: "hostFeeIn"; + writable: true; + optional: true; }, { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "user"; + signer: true; }, { - "name": "userToken", - "writable": true + name: "tokenXProgram"; }, { - "name": "reserve", - "writable": true + name: "tokenYProgram"; }, { - "name": "tokenMint" + name: "memoProgram"; + address: "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"; }, { - "name": "sender", - "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": "tokenProgram" - }, + name: "program"; + } + ]; + args: [ { - "name": "eventAuthority" + name: "amountIn"; + type: "u64"; }, { - "name": "program" - } - ], - "args": [ - { - "name": "liquidityParameter", - "type": { - "defined": { - "name": "addLiquiditySingleSidePreciseParameter2" - } - } + name: "minAmountOut"; + type: "u64"; }, { - "name": "remainingAccountsInfo", - "type": { - "defined": { - "name": "remainingAccountsInfo" - } - } + name: "remainingAccountsInfo"; + type: { + defined: { + name: "remainingAccountsInfo"; + }; + }; } - ] + ]; }, { - "name": "removeLiquidity2", - "discriminator": [ - 230, - 215, - 82, - 127, - 241, - 101, - 227, - 146 - ], - "accounts": [ + name: "swapExactOut"; + discriminator: [250, 73, 101, 33, 38, 207, 75, 184]; + accounts: [ { - "name": "position", - "writable": true + name: "lbPair"; + writable: true; + relations: ["binArrayBitmapExtension"]; }, { - "name": "lbPair", - "writable": true + name: "binArrayBitmapExtension"; + optional: true; }, { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "userTokenX", - "writable": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "userTokenY", - "writable": true + name: "userTokenIn"; + writable: true; }, { - "name": "reserveX", - "writable": true + name: "userTokenOut"; + writable: true; }, { - "name": "reserveY", - "writable": true + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "tokenXMint" + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "tokenYMint" + name: "oracle"; + writable: true; + relations: ["lbPair"]; }, { - "name": "sender", - "signer": true + name: "hostFeeIn"; + writable: true; + optional: true; }, { - "name": "tokenXProgram" + name: "user"; + signer: true; }, { - "name": "tokenYProgram" + name: "tokenXProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "memoProgram" + name: "tokenYProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [ - { - "name": "binLiquidityRemoval", - "type": { - "vec": { - "defined": { - "name": "binLiquidityReduction" - } - } - } + ]; + args: [ + { + name: "maxInAmount"; + type: "u64"; }, { - "name": "remainingAccountsInfo", - "type": { - "defined": { - "name": "remainingAccountsInfo" - } - } + name: "outAmount"; + type: "u64"; } - ] + ]; }, { - "name": "removeLiquidityByRange2", - "discriminator": [ - 204, - 2, - 195, - 145, - 53, - 145, - 145, - 205 - ], - "accounts": [ + name: "swapExactOut2"; + discriminator: [43, 215, 247, 132, 137, 60, 243, 81]; + accounts: [ { - "name": "position", - "writable": true + name: "lbPair"; + writable: true; + relations: ["binArrayBitmapExtension"]; }, { - "name": "lbPair", - "writable": true + name: "binArrayBitmapExtension"; + optional: true; }, { - "name": "binArrayBitmapExtension", - "writable": true, - "optional": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "userTokenX", - "writable": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "userTokenY", - "writable": true + name: "userTokenIn"; + writable: true; }, { - "name": "reserveX", - "writable": true + name: "userTokenOut"; + writable: true; }, { - "name": "reserveY", - "writable": true + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "tokenXMint" + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "tokenYMint" + name: "oracle"; + writable: true; + relations: ["lbPair"]; }, { - "name": "sender", - "signer": true + name: "hostFeeIn"; + writable: true; + optional: true; }, { - "name": "tokenXProgram" + name: "user"; + signer: true; }, { - "name": "tokenYProgram" + name: "tokenXProgram"; }, { - "name": "memoProgram" + name: "tokenYProgram"; }, { - "name": "eventAuthority" + name: "memoProgram"; + address: "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"; }, { - "name": "program" - } - ], - "args": [ - { - "name": "fromBinId", - "type": "i32" + 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": "toBinId", - "type": "i32" + name: "program"; + } + ]; + args: [ + { + name: "maxInAmount"; + type: "u64"; }, { - "name": "bpsToRemove", - "type": "u16" + name: "outAmount"; + type: "u64"; }, { - "name": "remainingAccountsInfo", - "type": { - "defined": { - "name": "remainingAccountsInfo" - } - } + name: "remainingAccountsInfo"; + type: { + defined: { + name: "remainingAccountsInfo"; + }; + }; } - ] + ]; }, { - "name": "swap2", - "discriminator": [ - 65, - 75, - 63, - 76, - 235, - 91, - 91, - 136 - ], - "accounts": [ - { - "name": "lbPair", - "writable": true - }, + name: "swapWithPriceImpact"; + discriminator: [56, 173, 230, 208, 173, 228, 156, 205]; + accounts: [ { - "name": "binArrayBitmapExtension", - "optional": true + name: "lbPair"; + writable: true; + relations: ["binArrayBitmapExtension"]; }, { - "name": "reserveX", - "writable": true + name: "binArrayBitmapExtension"; + optional: true; }, { - "name": "reserveY", - "writable": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "userTokenIn", - "writable": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "userTokenOut", - "writable": true + name: "userTokenIn"; + writable: true; }, { - "name": "tokenXMint" + name: "userTokenOut"; + writable: true; }, { - "name": "tokenYMint" + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "oracle", - "writable": true + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "hostFeeIn", - "writable": true, - "optional": true + name: "oracle"; + writable: true; + relations: ["lbPair"]; }, { - "name": "user", - "signer": true + name: "hostFeeIn"; + writable: true; + optional: true; }, { - "name": "tokenXProgram" + name: "user"; + signer: true; }, { - "name": "tokenYProgram" + name: "tokenXProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "memoProgram" + name: "tokenYProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [ + ]; + args: [ { - "name": "amountIn", - "type": "u64" + name: "amountIn"; + type: "u64"; }, { - "name": "minAmountOut", - "type": "u64" + name: "activeId"; + type: { + option: "i32"; + }; }, { - "name": "remainingAccountsInfo", - "type": { - "defined": { - "name": "remainingAccountsInfo" - } - } + name: "maxPriceImpactBps"; + type: "u16"; } - ] + ]; }, { - "name": "swapExactOut2", - "discriminator": [ - 43, - 215, - 247, - 132, - 137, - 60, - 243, - 81 - ], - "accounts": [ + name: "swapWithPriceImpact2"; + discriminator: [74, 98, 192, 214, 177, 51, 75, 51]; + accounts: [ { - "name": "lbPair", - "writable": true + name: "lbPair"; + writable: true; + relations: ["binArrayBitmapExtension"]; }, { - "name": "binArrayBitmapExtension", - "optional": true + name: "binArrayBitmapExtension"; + optional: true; }, { - "name": "reserveX", - "writable": true + name: "reserveX"; + writable: true; + relations: ["lbPair"]; }, { - "name": "reserveY", - "writable": true + name: "reserveY"; + writable: true; + relations: ["lbPair"]; }, { - "name": "userTokenIn", - "writable": true + name: "userTokenIn"; + writable: true; }, { - "name": "userTokenOut", - "writable": true + name: "userTokenOut"; + writable: true; }, { - "name": "tokenXMint" + name: "tokenXMint"; + relations: ["lbPair"]; }, { - "name": "tokenYMint" + name: "tokenYMint"; + relations: ["lbPair"]; }, { - "name": "oracle", - "writable": true + name: "oracle"; + writable: true; + relations: ["lbPair"]; }, { - "name": "hostFeeIn", - "writable": true, - "optional": true + name: "hostFeeIn"; + writable: true; + optional: true; }, { - "name": "user", - "signer": true + name: "user"; + signer: true; }, { - "name": "tokenXProgram" + name: "tokenXProgram"; }, { - "name": "tokenYProgram" + name: "tokenYProgram"; }, { - "name": "memoProgram" + name: "memoProgram"; + address: "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"; }, { - "name": "eventAuthority" + 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" + name: "program"; } - ], - "args": [ + ]; + args: [ { - "name": "maxInAmount", - "type": "u64" + name: "amountIn"; + type: "u64"; }, { - "name": "outAmount", - "type": "u64" + name: "activeId"; + type: { + option: "i32"; + }; }, { - "name": "remainingAccountsInfo", - "type": { - "defined": { - "name": "remainingAccountsInfo" - } - } - } - ] - }, - { - "name": "swapWithPriceImpact2", - "discriminator": [ - 74, - 98, - 192, - 214, - 177, - 51, - 75, - 51 - ], - "accounts": [ - { - "name": "lbPair", - "writable": true + name: "maxPriceImpactBps"; + type: "u16"; }, { - "name": "binArrayBitmapExtension", - "optional": true + name: "remainingAccountsInfo"; + type: { + defined: { + name: "remainingAccountsInfo"; + }; + }; + } + ]; + }, + { + name: "updateBaseFeeParameters"; + discriminator: [75, 168, 223, 161, 16, 195, 3, 47]; + accounts: [ + { + name: "lbPair"; + 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": "reserveX", - "writable": true + name: "program"; + } + ]; + args: [ + { + name: "feeParameter"; + type: { + defined: { + name: "baseFeeParameter"; + }; + }; + } + ]; + }, + { + name: "updateDynamicFeeParameters"; + discriminator: [92, 161, 46, 246, 255, 189, 22, 22]; + accounts: [ + { + name: "lbPair"; + 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": "reserveY", - "writable": true - }, + name: "program"; + } + ]; + args: [ + { + name: "feeParameter"; + type: { + defined: { + name: "dynamicFeeParameter"; + }; + }; + } + ]; + }, + { + name: "updateFeesAndReward2"; + discriminator: [32, 142, 184, 154, 103, 65, 184, 88]; + accounts: [ { - "name": "userTokenIn", - "writable": true + name: "position"; + writable: true; }, { - "name": "userTokenOut", - "writable": true + name: "lbPair"; + writable: true; + relations: ["position"]; }, { - "name": "tokenXMint" - }, + name: "owner"; + signer: true; + } + ]; + args: [ { - "name": "tokenYMint" + name: "minBinId"; + type: "i32"; }, { - "name": "oracle", - "writable": true - }, + name: "maxBinId"; + type: "i32"; + } + ]; + }, + { + name: "updateFeesAndRewards"; + discriminator: [154, 230, 250, 13, 236, 209, 75, 223]; + accounts: [ { - "name": "hostFeeIn", - "writable": true, - "optional": true + name: "position"; + writable: true; }, { - "name": "user", - "signer": true + name: "lbPair"; + writable: true; + relations: ["position", "binArrayLower", "binArrayUpper"]; }, { - "name": "tokenXProgram" + name: "binArrayLower"; + writable: true; }, { - "name": "tokenYProgram" + name: "binArrayUpper"; + writable: true; }, { - "name": "memoProgram" + name: "owner"; + signer: true; + } + ]; + args: []; + }, + { + name: "updatePositionOperator"; + discriminator: [202, 184, 103, 143, 180, 191, 116, 217]; + accounts: [ + { + name: "position"; + writable: true; + }, + { + name: "owner"; + signer: true; + relations: ["position"]; + }, + { + 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": "eventAuthority" + name: "program"; + } + ]; + args: [ + { + name: "operator"; + type: "pubkey"; + } + ]; + }, + { + name: "updateRewardDuration"; + discriminator: [138, 174, 196, 169, 213, 235, 254, 107]; + accounts: [ + { + name: "lbPair"; + writable: true; + relations: ["binArray"]; + }, + { + name: "admin"; + signer: true; + }, + { + name: "binArray"; + 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" + name: "program"; } - ], - "args": [ + ]; + args: [ { - "name": "amountIn", - "type": "u64" + name: "rewardIndex"; + type: "u64"; }, { - "name": "activeId", - "type": { - "option": "i32" - } + name: "newDuration"; + type: "u64"; + } + ]; + }, + { + name: "updateRewardFunder"; + discriminator: [211, 28, 48, 32, 215, 160, 35, 23]; + accounts: [ + { + name: "lbPair"; + 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": "maxPriceImpactBps", - "type": "u16" + name: "program"; + } + ]; + args: [ + { + name: "rewardIndex"; + type: "u64"; }, { - "name": "remainingAccountsInfo", - "type": { - "defined": { - "name": "remainingAccountsInfo" - } - } + name: "newFunder"; + type: "pubkey"; } - ] + ]; }, { - "name": "closePosition2", - "discriminator": [ - 174, - 90, - 35, - 115, - 186, - 40, - 147, - 226 - ], - "accounts": [ + name: "withdrawIneligibleReward"; + discriminator: [148, 206, 42, 195, 247, 49, 103, 8]; + accounts: [ { - "name": "position", - "writable": true + name: "lbPair"; + writable: true; + relations: ["binArray"]; }, { - "name": "sender", - "signer": true + name: "rewardVault"; + writable: true; }, { - "name": "rentReceiver", - "writable": true + name: "rewardMint"; }, { - "name": "eventAuthority" + name: "funderTokenAccount"; + writable: true; }, { - "name": "program" - } - ], - "args": [] - }, - { - "name": "updateFeesAndReward2", - "discriminator": [ - 32, - 142, - 184, - 154, - 103, - 65, - 184, - 88 - ], - "accounts": [ + name: "funder"; + signer: true; + }, { - "name": "position", - "writable": true + name: "binArray"; + writable: true; }, { - "name": "lbPair", - "writable": true + name: "tokenProgram"; }, { - "name": "owner", - "signer": true - } - ], - "args": [ + name: "memoProgram"; + address: "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"; + }, { - "name": "minBinId", - "type": "i32" + 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": "maxBinId", - "type": "i32" + name: "program"; } - ] - }, - { - "name": "closePositionIfEmpty", - "discriminator": [ - 59, - 124, - 212, - 118, - 91, - 152, - 110, - 157 - ], - "accounts": [ + ]; + args: [ { - "name": "position", - "writable": true + name: "rewardIndex"; + type: "u64"; }, { - "name": "sender", - "signer": true - }, + name: "remainingAccountsInfo"; + type: { + defined: { + name: "remainingAccountsInfo"; + }; + }; + } + ]; + }, + { + name: "withdrawProtocolFee"; + discriminator: [158, 201, 158, 189, 33, 93, 162, 103]; + accounts: [ + { + name: "lbPair"; + writable: true; + }, + { + name: "reserveX"; + writable: true; + relations: ["lbPair"]; + }, + { + name: "reserveY"; + writable: true; + relations: ["lbPair"]; + }, + { + name: "tokenXMint"; + relations: ["lbPair"]; + }, + { + name: "tokenYMint"; + relations: ["lbPair"]; + }, + { + name: "receiverTokenX"; + 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: "tokenXProgram"; + }, + { + kind: "account"; + path: "tokenXMint"; + } + ]; + 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: "receiverTokenY"; + 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: "tokenYProgram"; + }, + { + kind: "account"; + path: "tokenYMint"; + } + ]; + program: { + kind: "const"; + value: [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ]; + }; + }; + }, + { + name: "claimFeeOperator"; + }, + { + name: "operator"; + docs: ["operator"]; + signer: true; + relations: ["claimFeeOperator"]; + }, + { + name: "tokenXProgram"; + }, + { + name: "tokenYProgram"; + }, + { + name: "memoProgram"; + address: "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"; + } + ]; + args: [ { - "name": "rentReceiver", - "writable": true + name: "maxAmountX"; + type: "u64"; }, { - "name": "eventAuthority" + name: "maxAmountY"; + type: "u64"; }, { - "name": "program" + name: "remainingAccountsInfo"; + type: { + defined: { + name: "remainingAccountsInfo"; + }; + }; } - ], - "args": [] - } - ], - "accounts": [ - { - "name": "binArrayBitmapExtension", - "discriminator": [ - 80, - 111, - 124, - 113, - 55, - 237, - 18, - 5 - ] - }, - { - "name": "claimFeeOperator", - "discriminator": [ - 166, - 48, - 134, - 86, - 34, - 200, - 188, - 150 - ] - }, - { - "name": "lbPair", - "discriminator": [ - 33, - 11, - 49, - 98, - 181, - 101, - 177, - 13 - ] - }, - { - "name": "oracle", - "discriminator": [ - 139, - 194, - 131, - 179, - 140, - 179, - 229, - 244 - ] - }, - { - "name": "presetParameter2", - "discriminator": [ - 171, - 236, - 148, - 115, - 162, - 113, - 222, - 174 - ] - }, - { - "name": "presetParameter", - "discriminator": [ - 242, - 62, - 244, - 34, - 181, - 112, - 58, - 170 - ] - }, - { - "name": "tokenBadge", - "discriminator": [ - 116, - 219, - 204, - 229, - 249, - 116, - 255, - 150 - ] + ]; } - ], - "events": [ - { - "name": "compositionFee", - "discriminator": [ - 128, - 151, - 123, - 106, - 17, - 102, - 113, - 142 - ] - }, - { - "name": "addLiquidity", - "discriminator": [ - 31, - 94, - 125, - 90, - 227, - 52, - 61, - 186 - ] - }, - { - "name": "removeLiquidity", - "discriminator": [ - 116, - 244, - 97, - 232, - 103, - 31, - 152, - 58 - ] - }, - { - "name": "swap", - "discriminator": [ - 81, - 108, - 227, - 190, - 205, - 208, - 10, - 196 - ] - }, - { - "name": "claimReward", - "discriminator": [ - 148, - 116, - 134, - 204, - 22, - 171, - 85, - 95 - ] - }, - { - "name": "fundReward", - "discriminator": [ - 246, - 228, - 58, - 130, - 145, - 170, - 79, - 204 - ] - }, - { - "name": "initializeReward", - "discriminator": [ - 211, - 153, - 88, - 62, - 149, - 60, - 177, - 70 - ] - }, - { - "name": "updateRewardDuration", - "discriminator": [ - 223, - 245, - 224, - 153, - 49, - 29, - 163, - 172 - ] - }, - { - "name": "updateRewardFunder", - "discriminator": [ - 224, - 178, - 174, - 74, - 252, - 165, - 85, - 180 - ] - }, - { - "name": "positionClose", - "discriminator": [ - 255, - 196, - 16, - 107, - 28, - 202, - 53, - 128 - ] - }, - { - "name": "claimFee", - "discriminator": [ - 75, - 122, - 154, - 48, - 140, - 74, - 123, - 163 - ] - }, - { - "name": "lbPairCreate", - "discriminator": [ - 185, - 74, - 252, - 125, - 27, - 215, - 188, - 111 - ] - }, - { - "name": "positionCreate", - "discriminator": [ - 144, - 142, - 252, - 84, - 157, - 53, - 37, - 121 - ] - }, - { - "name": "increasePositionLength", - "discriminator": [ - 157, - 239, - 42, - 204, - 30, - 56, - 223, - 46 - ] - }, - { - "name": "decreasePositionLength", - "discriminator": [ - 52, - 118, - 235, - 85, - 172, - 169, - 15, - 128 - ] - }, - { - "name": "feeParameterUpdate", - "discriminator": [ - 48, - 76, - 241, - 117, - 144, - 215, - 242, - 44 - ] - }, - { - "name": "dynamicFeeParameterUpdate", - "discriminator": [ - 88, - 88, - 178, - 135, - 194, - 146, - 91, - 243 - ] - }, - { - "name": "increaseObservation", - "discriminator": [ - 99, - 249, - 17, - 121, - 166, - 156, - 207, - 215 - ] - }, - { - "name": "withdrawIneligibleReward", - "discriminator": [ - 231, - 189, - 65, - 149, - 102, - 215, - 154, - 244 - ] - }, - { - "name": "updatePositionOperator", - "discriminator": [ - 39, - 115, - 48, - 204, - 246, - 47, - 66, - 57 - ] - }, - { - "name": "updatePositionLockReleasePoint", - "discriminator": [ - 133, - 214, - 66, - 224, - 64, - 12, - 7, - 191 - ] - }, - { - "name": "goToABin", - "discriminator": [ - 59, - 138, - 76, - 68, - 138, - 131, - 176, - 67 - ] - } - ], - "errors": [ + ]; + accounts: [ { - "code": 6000, - "name": "invalidStartBinIndex", - "msg": "Invalid start bin index" + name: "binArray"; + discriminator: [92, 142, 92, 220, 5, 148, 70, 181]; }, { - "code": 6001, - "name": "invalidBinId", - "msg": "Invalid bin id" + name: "binArrayBitmapExtension"; + discriminator: [80, 111, 124, 113, 55, 237, 18, 5]; }, { - "code": 6002, - "name": "invalidInput", - "msg": "Invalid input data" + name: "claimFeeOperator"; + discriminator: [166, 48, 134, 86, 34, 200, 188, 150]; }, { - "code": 6003, - "name": "exceededAmountSlippageTolerance", - "msg": "Exceeded amount slippage tolerance" + name: "dummyZcAccount"; + discriminator: [94, 107, 238, 80, 208, 48, 180, 8]; }, { - "code": 6004, - "name": "exceededBinSlippageTolerance", - "msg": "Exceeded bin slippage tolerance" + name: "lbPair"; + discriminator: [33, 11, 49, 98, 181, 101, 177, 13]; }, { - "code": 6005, - "name": "compositionFactorFlawed", - "msg": "Composition factor flawed" + name: "oracle"; + discriminator: [139, 194, 131, 179, 140, 179, 229, 244]; }, { - "code": 6006, - "name": "nonPresetBinStep", - "msg": "Non preset bin step" + name: "position"; + discriminator: [170, 188, 143, 228, 122, 64, 247, 208]; }, { - "code": 6007, - "name": "zeroLiquidity", - "msg": "Zero liquidity" + name: "positionV2"; + discriminator: [117, 176, 212, 199, 245, 180, 133, 182]; }, { - "code": 6008, - "name": "invalidPosition", - "msg": "Invalid position" + name: "presetParameter"; + discriminator: [242, 62, 244, 34, 181, 112, 58, 170]; }, { - "code": 6009, - "name": "binArrayNotFound", - "msg": "Bin array not found" + name: "presetParameter2"; + discriminator: [171, 236, 148, 115, 162, 113, 222, 174]; }, { - "code": 6010, - "name": "invalidTokenMint", - "msg": "Invalid token mint" + name: "tokenBadge"; + discriminator: [116, 219, 204, 229, 249, 116, 255, 150]; + } + ]; + events: [ + { + name: "addLiquidity"; + discriminator: [31, 94, 125, 90, 227, 52, 61, 186]; }, { - "code": 6011, - "name": "invalidAccountForSingleDeposit", - "msg": "Invalid account for single deposit" + name: "claimFee"; + discriminator: [75, 122, 154, 48, 140, 74, 123, 163]; }, { - "code": 6012, - "name": "pairInsufficientLiquidity", - "msg": "Pair insufficient liquidity" + name: "claimFee2"; + discriminator: [232, 171, 242, 97, 58, 77, 35, 45]; }, { - "code": 6013, - "name": "invalidFeeOwner", - "msg": "Invalid fee owner" + name: "claimReward"; + discriminator: [148, 116, 134, 204, 22, 171, 85, 95]; }, { - "code": 6014, - "name": "invalidFeeWithdrawAmount", - "msg": "Invalid fee withdraw amount" + name: "claimReward2"; + discriminator: [27, 143, 244, 33, 80, 43, 110, 146]; }, { - "code": 6015, - "name": "invalidAdmin", - "msg": "Invalid admin" + name: "compositionFee"; + discriminator: [128, 151, 123, 106, 17, 102, 113, 142]; }, { - "code": 6016, - "name": "identicalFeeOwner", - "msg": "Identical fee owner" + name: "decreasePositionLength"; + discriminator: [52, 118, 235, 85, 172, 169, 15, 128]; }, { - "code": 6017, - "name": "invalidBps", - "msg": "Invalid basis point" + name: "dynamicFeeParameterUpdate"; + discriminator: [88, 88, 178, 135, 194, 146, 91, 243]; }, { - "code": 6018, - "name": "mathOverflow", - "msg": "Math operation overflow" + name: "feeParameterUpdate"; + discriminator: [48, 76, 241, 117, 144, 215, 242, 44]; }, { - "code": 6019, - "name": "typeCastFailed", - "msg": "Type cast error" + name: "fundReward"; + discriminator: [246, 228, 58, 130, 145, 170, 79, 204]; }, { - "code": 6020, - "name": "invalidRewardIndex", - "msg": "Invalid reward index" + name: "goToABin"; + discriminator: [59, 138, 76, 68, 138, 131, 176, 67]; }, { - "code": 6021, - "name": "invalidRewardDuration", - "msg": "Invalid reward duration" + name: "increaseObservation"; + discriminator: [99, 249, 17, 121, 166, 156, 207, 215]; }, { - "code": 6022, - "name": "rewardInitialized", - "msg": "Reward already initialized" + name: "increasePositionLength"; + discriminator: [157, 239, 42, 204, 30, 56, 223, 46]; }, { - "code": 6023, - "name": "rewardUninitialized", - "msg": "Reward not initialized" + name: "initializeReward"; + discriminator: [211, 153, 88, 62, 149, 60, 177, 70]; }, { - "code": 6024, - "name": "identicalFunder", - "msg": "Identical funder" + name: "lbPairCreate"; + discriminator: [185, 74, 252, 125, 27, 215, 188, 111]; }, { - "code": 6025, - "name": "rewardCampaignInProgress", - "msg": "Reward campaign in progress" + name: "positionClose"; + discriminator: [255, 196, 16, 107, 28, 202, 53, 128]; }, { - "code": 6026, - "name": "identicalRewardDuration", - "msg": "Reward duration is the same" + name: "positionCreate"; + discriminator: [144, 142, 252, 84, 157, 53, 37, 121]; }, { - "code": 6027, - "name": "invalidBinArray", - "msg": "Invalid bin array" + name: "rebalancing"; + discriminator: [0, 109, 117, 179, 61, 91, 199, 200]; }, { - "code": 6028, - "name": "nonContinuousBinArrays", - "msg": "Bin arrays must be continuous" + name: "removeLiquidity"; + discriminator: [116, 244, 97, 232, 103, 31, 152, 58]; }, { - "code": 6029, - "name": "invalidRewardVault", - "msg": "Invalid reward vault" + name: "swap"; + discriminator: [81, 108, 227, 190, 205, 208, 10, 196]; }, { - "code": 6030, - "name": "nonEmptyPosition", - "msg": "Position is not empty" + name: "updatePositionLockReleasePoint"; + discriminator: [133, 214, 66, 224, 64, 12, 7, 191]; }, { - "code": 6031, - "name": "unauthorizedAccess", - "msg": "Unauthorized access" + name: "updatePositionOperator"; + discriminator: [39, 115, 48, 204, 246, 47, 66, 57]; }, { - "code": 6032, - "name": "invalidFeeParameter", - "msg": "Invalid fee parameter" + name: "updateRewardDuration"; + discriminator: [223, 245, 224, 153, 49, 29, 163, 172]; }, { - "code": 6033, - "name": "missingOracle", - "msg": "Missing oracle account" + name: "updateRewardFunder"; + discriminator: [224, 178, 174, 74, 252, 165, 85, 180]; }, { - "code": 6034, - "name": "insufficientSample", - "msg": "Insufficient observation sample" + name: "withdrawIneligibleReward"; + discriminator: [231, 189, 65, 149, 102, 215, 154, 244]; + } + ]; + errors: [ + { + code: 6000; + name: "invalidStartBinIndex"; + msg: "Invalid start bin index"; }, { - "code": 6035, - "name": "invalidLookupTimestamp", - "msg": "Invalid lookup timestamp" + code: 6001; + name: "invalidBinId"; + msg: "Invalid bin id"; }, { - "code": 6036, - "name": "bitmapExtensionAccountIsNotProvided", - "msg": "Bitmap extension account is not provided" + code: 6002; + name: "invalidInput"; + msg: "Invalid input data"; }, { - "code": 6037, - "name": "cannotFindNonZeroLiquidityBinArrayId", - "msg": "Cannot find non-zero liquidity binArrayId" + code: 6003; + name: "exceededAmountSlippageTolerance"; + msg: "Exceeded amount slippage tolerance"; }, { - "code": 6038, - "name": "binIdOutOfBound", - "msg": "Bin id out of bound" + code: 6004; + name: "exceededBinSlippageTolerance"; + msg: "Exceeded bin slippage tolerance"; }, { - "code": 6039, - "name": "insufficientOutAmount", - "msg": "Insufficient amount in for minimum out" + code: 6005; + name: "compositionFactorFlawed"; + msg: "Composition factor flawed"; }, { - "code": 6040, - "name": "invalidPositionWidth", - "msg": "Invalid position width" + code: 6006; + name: "nonPresetBinStep"; + msg: "Non preset bin step"; }, { - "code": 6041, - "name": "excessiveFeeUpdate", - "msg": "Excessive fee update" + code: 6007; + name: "zeroLiquidity"; + msg: "Zero liquidity"; }, { - "code": 6042, - "name": "poolDisabled", - "msg": "Pool disabled" + code: 6008; + name: "invalidPosition"; + msg: "Invalid position"; }, { - "code": 6043, - "name": "invalidPoolType", - "msg": "Invalid pool type" + code: 6009; + name: "binArrayNotFound"; + msg: "Bin array not found"; }, { - "code": 6044, - "name": "exceedMaxWhitelist", - "msg": "Whitelist for wallet is full" + code: 6010; + name: "invalidTokenMint"; + msg: "Invalid token mint"; }, { - "code": 6045, - "name": "invalidIndex", - "msg": "Invalid index" + code: 6011; + name: "invalidAccountForSingleDeposit"; + msg: "Invalid account for single deposit"; }, { - "code": 6046, - "name": "rewardNotEnded", - "msg": "Reward not ended" + code: 6012; + name: "pairInsufficientLiquidity"; + msg: "Pair insufficient liquidity"; }, { - "code": 6047, - "name": "mustWithdrawnIneligibleReward", - "msg": "Must withdraw ineligible reward" + code: 6013; + name: "invalidFeeOwner"; + msg: "Invalid fee owner"; }, { - "code": 6048, - "name": "unauthorizedAddress", - "msg": "Unauthorized address" + code: 6014; + name: "invalidFeeWithdrawAmount"; + msg: "Invalid fee withdraw amount"; }, { - "code": 6049, - "name": "operatorsAreTheSame", - "msg": "Cannot update because operators are the same" + code: 6015; + name: "invalidAdmin"; + msg: "Invalid admin"; }, { - "code": 6050, - "name": "withdrawToWrongTokenAccount", - "msg": "Withdraw to wrong token account" + code: 6016; + name: "identicalFeeOwner"; + msg: "Identical fee owner"; }, { - "code": 6051, - "name": "wrongRentReceiver", - "msg": "Wrong rent receiver" + code: 6017; + name: "invalidBps"; + msg: "Invalid basis point"; }, { - "code": 6052, - "name": "alreadyPassActivationPoint", - "msg": "Already activated" + code: 6018; + name: "mathOverflow"; + msg: "Math operation overflow"; }, { - "code": 6053, - "name": "exceedMaxSwappedAmount", - "msg": "Swapped amount is exceeded max swapped amount" + code: 6019; + name: "typeCastFailed"; + msg: "Type cast error"; }, { - "code": 6054, - "name": "invalidStrategyParameters", - "msg": "Invalid strategy parameters" + code: 6020; + name: "invalidRewardIndex"; + msg: "Invalid reward index"; }, { - "code": 6055, - "name": "liquidityLocked", - "msg": "Liquidity locked" + code: 6021; + name: "invalidRewardDuration"; + msg: "Invalid reward duration"; }, { - "code": 6056, - "name": "binRangeIsNotEmpty", - "msg": "Bin range is not empty" + code: 6022; + name: "rewardInitialized"; + msg: "Reward already initialized"; }, { - "code": 6057, - "name": "notExactAmountOut", - "msg": "Amount out is not matched with exact amount out" + code: 6023; + name: "rewardUninitialized"; + msg: "Reward not initialized"; }, { - "code": 6058, - "name": "invalidActivationType", - "msg": "Invalid activation type" + code: 6024; + name: "identicalFunder"; + msg: "Identical funder"; }, { - "code": 6059, - "name": "invalidActivationDuration", - "msg": "Invalid activation duration" + code: 6025; + name: "rewardCampaignInProgress"; + msg: "Reward campaign in progress"; }, { - "code": 6060, - "name": "missingTokenAmountAsTokenLaunchProof", - "msg": "Missing token amount as token launch owner proof" + code: 6026; + name: "identicalRewardDuration"; + msg: "Reward duration is the same"; }, { - "code": 6061, - "name": "invalidQuoteToken", - "msg": "Quote token must be SOL or USDC" + code: 6027; + name: "invalidBinArray"; + msg: "Invalid bin array"; }, { - "code": 6062, - "name": "invalidBinStep", - "msg": "Invalid bin step" + code: 6028; + name: "nonContinuousBinArrays"; + msg: "Bin arrays must be continuous"; }, { - "code": 6063, - "name": "invalidBaseFee", - "msg": "Invalid base fee" + code: 6029; + name: "invalidRewardVault"; + msg: "Invalid reward vault"; }, { - "code": 6064, - "name": "invalidPreActivationDuration", - "msg": "Invalid pre-activation duration" + code: 6030; + name: "nonEmptyPosition"; + msg: "Position is not empty"; }, { - "code": 6065, - "name": "alreadyPassPreActivationSwapPoint", - "msg": "Already pass pre-activation swap point" + code: 6031; + name: "unauthorizedAccess"; + msg: "Unauthorized access"; }, { - "code": 6066, - "name": "invalidStatus", - "msg": "Invalid status" + code: 6032; + name: "invalidFeeParameter"; + msg: "Invalid fee parameter"; }, { - "code": 6067, - "name": "exceededMaxOracleLength", - "msg": "Exceed max oracle length" + code: 6033; + name: "missingOracle"; + msg: "Missing oracle account"; }, { - "code": 6068, - "name": "invalidMinimumLiquidity", - "msg": "Invalid minimum liquidity" + code: 6034; + name: "insufficientSample"; + msg: "Insufficient observation sample"; }, { - "code": 6069, - "name": "notSupportMint", - "msg": "Not support token_2022 mint extension" + code: 6035; + name: "invalidLookupTimestamp"; + msg: "Invalid lookup timestamp"; }, { - "code": 6070, - "name": "unsupportedMintExtension", - "msg": "Unsupported mint extension" + code: 6036; + name: "bitmapExtensionAccountIsNotProvided"; + msg: "Bitmap extension account is not provided"; }, { - "code": 6071, - "name": "unsupportNativeMintToken2022", - "msg": "Unsupported native mint token2022" + code: 6037; + name: "cannotFindNonZeroLiquidityBinArrayId"; + msg: "Cannot find non-zero liquidity binArrayId"; }, { - "code": 6072, - "name": "unmatchTokenMint", - "msg": "Unmatch token mint" + code: 6038; + name: "binIdOutOfBound"; + msg: "Bin id out of bound"; }, { - "code": 6073, - "name": "unsupportedTokenMint", - "msg": "Unsupported token mint" + code: 6039; + name: "insufficientOutAmount"; + msg: "Insufficient amount in for minimum out"; }, { - "code": 6074, - "name": "insufficientRemainingAccounts", - "msg": "Insufficient remaining accounts" + code: 6040; + name: "invalidPositionWidth"; + msg: "Invalid position width"; }, { - "code": 6075, - "name": "invalidRemainingAccountSlice", - "msg": "Invalid remaining account slice" + code: 6041; + name: "excessiveFeeUpdate"; + msg: "Excessive fee update"; }, { - "code": 6076, - "name": "duplicatedRemainingAccountTypes", - "msg": "Duplicated remaining account types" + code: 6042; + name: "poolDisabled"; + msg: "Pool disabled"; }, { - "code": 6077, - "name": "missingRemainingAccountForTransferHook", - "msg": "Missing remaining account for transfer hook" + code: 6043; + name: "invalidPoolType"; + msg: "Invalid pool type"; }, { - "code": 6078, - "name": "noTransferHookProgram", - "msg": "Remaining account was passed for transfer hook but there's no hook program" + code: 6044; + name: "exceedMaxWhitelist"; + msg: "Whitelist for wallet is full"; }, { - "code": 6079, - "name": "zeroFundedAmount", - "msg": "Zero funded amount" + code: 6045; + name: "invalidIndex"; + msg: "Invalid index"; }, { - "code": 6080, - "name": "invalidSide", - "msg": "Invalid side" + code: 6046; + name: "rewardNotEnded"; + msg: "Reward not ended"; }, { - "code": 6081, - "name": "invalidResizeLength", - "msg": "Invalid resize length" + code: 6047; + name: "mustWithdrawnIneligibleReward"; + msg: "Must withdraw ineligible reward"; }, { - "code": 6082, - "name": "notSupportAtTheMoment", - "msg": "Not support at the moment" - } - ], - "types": [ + code: 6048; + name: "unauthorizedAddress"; + msg: "Unauthorized address"; + }, { - "name": "initPresetParameters2Ix", - "type": { - "kind": "struct", - "fields": [ - { - "name": "index", - "type": "u16" - }, - { - "name": "binStep", - "docs": [ - "Bin step. Represent the price increment / decrement." - ], - "type": "u16" - }, - { - "name": "baseFactor", - "docs": [ - "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" - ], - "type": "u16" - }, - { - "name": "filterPeriod", - "docs": [ - "Filter period determine high frequency trading time window." - ], - "type": "u16" - }, - { - "name": "decayPeriod", - "docs": [ - "Decay period determine when the volatile fee start decay / decrease." - ], - "type": "u16" - }, - { - "name": "reductionFactor", - "docs": [ - "Reduction factor controls the volatile fee rate decrement rate." - ], - "type": "u16" - }, - { - "name": "variableFeeControl", - "docs": [ - "Used to scale the variable fee component depending on the dynamic of the market" - ], - "type": "u32" + code: 6049; + name: "operatorsAreTheSame"; + msg: "Cannot update because operators are the same"; + }, + { + code: 6050; + name: "withdrawToWrongTokenAccount"; + msg: "Withdraw to wrong token account"; + }, + { + code: 6051; + name: "wrongRentReceiver"; + msg: "Wrong rent receiver"; + }, + { + code: 6052; + name: "alreadyPassActivationPoint"; + msg: "Already activated"; + }, + { + code: 6053; + name: "exceedMaxSwappedAmount"; + msg: "Swapped amount is exceeded max swapped amount"; + }, + { + code: 6054; + name: "invalidStrategyParameters"; + msg: "Invalid strategy parameters"; + }, + { + code: 6055; + name: "liquidityLocked"; + msg: "Liquidity locked"; + }, + { + code: 6056; + name: "binRangeIsNotEmpty"; + msg: "Bin range is not empty"; + }, + { + code: 6057; + name: "notExactAmountOut"; + msg: "Amount out is not matched with exact amount out"; + }, + { + code: 6058; + name: "invalidActivationType"; + msg: "Invalid activation type"; + }, + { + code: 6059; + name: "invalidActivationDuration"; + msg: "Invalid activation duration"; + }, + { + code: 6060; + name: "missingTokenAmountAsTokenLaunchProof"; + msg: "Missing token amount as token launch owner proof"; + }, + { + code: 6061; + name: "invalidQuoteToken"; + msg: "Quote token must be SOL or USDC"; + }, + { + code: 6062; + name: "invalidBinStep"; + msg: "Invalid bin step"; + }, + { + code: 6063; + name: "invalidBaseFee"; + msg: "Invalid base fee"; + }, + { + code: 6064; + name: "invalidPreActivationDuration"; + msg: "Invalid pre-activation duration"; + }, + { + code: 6065; + name: "alreadyPassPreActivationSwapPoint"; + msg: "Already pass pre-activation swap point"; + }, + { + code: 6066; + name: "invalidStatus"; + msg: "Invalid status"; + }, + { + code: 6067; + name: "exceededMaxOracleLength"; + msg: "Exceed max oracle length"; + }, + { + code: 6068; + name: "invalidMinimumLiquidity"; + msg: "Invalid minimum liquidity"; + }, + { + code: 6069; + name: "notSupportMint"; + msg: "Not support token_2022 mint extension"; + }, + { + code: 6070; + name: "unsupportedMintExtension"; + msg: "Unsupported mint extension"; + }, + { + code: 6071; + name: "unsupportNativeMintToken2022"; + msg: "Unsupported native mint token2022"; + }, + { + code: 6072; + name: "unmatchTokenMint"; + msg: "Unmatch token mint"; + }, + { + code: 6073; + name: "unsupportedTokenMint"; + msg: "Unsupported token mint"; + }, + { + code: 6074; + name: "insufficientRemainingAccounts"; + msg: "Insufficient remaining accounts"; + }, + { + code: 6075; + name: "invalidRemainingAccountSlice"; + msg: "Invalid remaining account slice"; + }, + { + code: 6076; + name: "duplicatedRemainingAccountTypes"; + msg: "Duplicated remaining account types"; + }, + { + code: 6077; + name: "missingRemainingAccountForTransferHook"; + msg: "Missing remaining account for transfer hook"; + }, + { + code: 6078; + name: "noTransferHookProgram"; + msg: "Remaining account was passed for transfer hook but there's no hook program"; + }, + { + code: 6079; + name: "zeroFundedAmount"; + msg: "Zero funded amount"; + }, + { + code: 6080; + name: "invalidSide"; + msg: "Invalid side"; + }, + { + code: 6081; + name: "invalidResizeLength"; + msg: "Invalid resize length"; + }, + { + code: 6082; + name: "notSupportAtTheMoment"; + msg: "Not support at the moment"; + }, + { + code: 6083; + name: "invalidRebalanceParameters"; + msg: "Invalid rebalance parameters"; + }, + { + code: 6084; + name: "invalidRewardAccounts"; + msg: "Invalid reward accounts"; + }, + { + code: 6085; + name: "undeterminedError"; + msg: "Undetermined error"; + }, + { + code: 6086; + name: "reallocExceedMaxLengthPerInstruction"; + msg: "Realloc exceed max length per instruction"; + }, + { + code: 6087; + name: "invalidBaseFeeMantissa"; + msg: "Mantissa cannot more than two significant digits"; + }, + { + code: 6088; + name: "invalidPositionOwner"; + msg: "Invalid position owner"; + }, + { + code: 6089; + name: "invalidPoolAddress"; + msg: "Invalid pool address"; + } + ]; + types: [ + { + name: "accountsType"; + type: { + kind: "enum"; + variants: [ + { + name: "transferHookX"; }, { - "name": "maxVolatilityAccumulator", - "docs": [ - "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." - ], - "type": "u32" + name: "transferHookY"; }, { - "name": "protocolShare", - "docs": [ - "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" + name: "transferHookReward"; }, { - "name": "baseFeePowerFactor", - "docs": [ - "Base fee power factor" - ], - "type": "u8" + name: "transferHookMultiReward"; + fields: ["u8"]; } - ] - } + ]; + }; }, { - "name": "initPresetParametersIx", - "type": { - "kind": "struct", - "fields": [ + name: "activationType"; + docs: ["Type of the activation"]; + repr: { + kind: "rust"; + }; + type: { + kind: "enum"; + variants: [ { - "name": "binStep", - "docs": [ - "Bin step. Represent the price increment / decrement." - ], - "type": "u16" + name: "slot"; }, { - "name": "baseFactor", - "docs": [ - "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" - ], - "type": "u16" + name: "timestamp"; + } + ]; + }; + }, + { + name: "addLiquidity"; + type: { + kind: "struct"; + fields: [ + { + name: "lbPair"; + type: "pubkey"; }, { - "name": "filterPeriod", - "docs": [ - "Filter period determine high frequency trading time window." - ], - "type": "u16" + name: "from"; + type: "pubkey"; }, { - "name": "decayPeriod", - "docs": [ - "Decay period determine when the volatile fee start decay / decrease." - ], - "type": "u16" + name: "position"; + type: "pubkey"; }, { - "name": "reductionFactor", - "docs": [ - "Reduction factor controls the volatile fee rate decrement rate." - ], - "type": "u16" + name: "amounts"; + type: { + array: ["u64", 2]; + }; }, { - "name": "variableFeeControl", - "docs": [ - "Used to scale the variable fee component depending on the dynamic of the market" - ], - "type": "u32" + name: "activeBinId"; + type: "i32"; + } + ]; + }; + }, + { + name: "addLiquidityParams"; + type: { + kind: "struct"; + fields: [ + { + name: "minDeltaId"; + type: "i32"; }, { - "name": "maxVolatilityAccumulator", - "docs": [ - "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." - ], - "type": "u32" + name: "maxDeltaId"; + type: "i32"; }, { - "name": "protocolShare", - "docs": [ - "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" + name: "x0"; + type: "u64"; + }, + { + name: "y0"; + type: "u64"; + }, + { + name: "deltaX"; + type: "u64"; + }, + { + name: "deltaY"; + type: "u64"; + }, + { + name: "bitFlag"; + type: "u8"; + }, + { + name: "favorXInActiveId"; + type: "bool"; + }, + { + name: "padding"; + type: { + array: ["u8", 16]; + }; } - ] - } + ]; + }; }, { - "name": "baseFeeParameter", - "type": { - "kind": "struct", - "fields": [ + name: "addLiquiditySingleSidePreciseParameter"; + type: { + kind: "struct"; + fields: [ { - "name": "protocolShare", - "docs": [ - "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" + name: "bins"; + type: { + vec: { + defined: { + name: "compressedBinDepositAmount"; + }; + }; + }; }, { - "name": "baseFactor", - "docs": [ - "Base factor for base fee rate" - ], - "type": "u16" - }, - { - "name": "baseFeePowerFactor", - "docs": [ - "Base fee power factor" - ], - "type": "u8" + name: "decompressMultiplier"; + type: "u64"; } - ] - } + ]; + }; }, { - "name": "dynamicFeeParameter", - "type": { - "kind": "struct", - "fields": [ + name: "addLiquiditySingleSidePreciseParameter2"; + type: { + kind: "struct"; + fields: [ { - "name": "filterPeriod", - "docs": [ - "Filter period determine high frequency trading time window." - ], - "type": "u16" + name: "bins"; + type: { + vec: { + defined: { + name: "compressedBinDepositAmount"; + }; + }; + }; }, { - "name": "decayPeriod", - "docs": [ - "Decay period determine when the volatile fee start decay / decrease." - ], - "type": "u16" + name: "decompressMultiplier"; + type: "u64"; }, { - "name": "reductionFactor", - "docs": [ - "Reduction factor controls the volatile fee rate decrement rate." - ], - "type": "u16" + name: "maxAmount"; + type: "u64"; + } + ]; + }; + }, + { + name: "baseFeeParameter"; + type: { + kind: "struct"; + fields: [ + { + name: "protocolShare"; + docs: [ + "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + ]; + type: "u16"; }, { - "name": "variableFeeControl", - "docs": [ - "Used to scale the variable fee component depending on the dynamic of the market" - ], - "type": "u32" + name: "baseFactor"; + docs: ["Base factor for base fee rate"]; + type: "u16"; }, { - "name": "maxVolatilityAccumulator", - "docs": [ - "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." - ], - "type": "u32" + name: "baseFeePowerFactor"; + docs: ["Base fee power factor"]; + type: "u8"; } - ] - } + ]; + }; }, { - "name": "liquidityParameterByStrategyOneSide", - "type": { - "kind": "struct", - "fields": [ + name: "bin"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ { - "name": "amount", - "docs": [ - "Amount of X token or Y token to deposit" - ], - "type": "u64" + name: "amountX"; + docs: [ + "Amount of token X in the bin. This already excluded protocol fees." + ]; + type: "u64"; }, { - "name": "activeId", - "docs": [ - "Active bin that integrator observe off-chain" - ], - "type": "i32" + name: "amountY"; + docs: [ + "Amount of token Y in the bin. This already excluded protocol fees." + ]; + type: "u64"; }, { - "name": "maxActiveBinSlippage", - "docs": [ - "max active bin slippage allowed" - ], - "type": "i32" + name: "price"; + docs: ["Bin price"]; + type: "u128"; }, { - "name": "strategyParameters", - "docs": [ - "strategy parameters" - ], - "type": { - "defined": { - "name": "strategyParameters" - } - } + name: "liquiditySupply"; + docs: [ + "Liquidities of the bin. This is the same as LP mint supply. q-number" + ]; + type: "u128"; + }, + { + name: "rewardPerTokenStored"; + docs: ["reward_a_per_token_stored"]; + type: { + array: ["u128", 2]; + }; + }, + { + name: "feeAmountXPerTokenStored"; + docs: ["Swap fee amount of token X per liquidity deposited."]; + type: "u128"; + }, + { + name: "feeAmountYPerTokenStored"; + docs: ["Swap fee amount of token Y per liquidity deposited."]; + type: "u128"; + }, + { + name: "amountXIn"; + docs: [ + "Total token X swap into the bin. Only used for tracking purpose." + ]; + type: "u128"; + }, + { + name: "amountYIn"; + docs: [ + "Total token Y swap into he bin. Only used for tracking purpose." + ]; + type: "u128"; } - ] - } + ]; + }; }, { - "name": "liquidityParameterByStrategy", - "type": { - "kind": "struct", - "fields": [ + name: "binArray"; + docs: [ + "An account to contain a range of bin. For example: Bin 100 <-> 200.", + "For example:", + "BinArray index: 0 contains bin 0 <-> 599", + "index: 2 contains bin 600 <-> 1199, ..." + ]; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ { - "name": "amountX", - "docs": [ - "Amount of X token to deposit" - ], - "type": "u64" + name: "index"; + type: "i64"; }, { - "name": "amountY", - "docs": [ - "Amount of Y token to deposit" - ], - "type": "u64" + name: "version"; + docs: ["Version of binArray"]; + type: "u8"; }, { - "name": "activeId", - "docs": [ - "Active bin that integrator observe off-chain" - ], - "type": "i32" + name: "padding"; + type: { + array: ["u8", 7]; + }; }, { - "name": "maxActiveBinSlippage", - "docs": [ - "max active bin slippage allowed" - ], - "type": "i32" + name: "lbPair"; + type: "pubkey"; }, { - "name": "strategyParameters", - "docs": [ - "strategy parameters" - ], - "type": { - "defined": { - "name": "strategyParameters" - } - } + name: "bins"; + type: { + array: [ + { + defined: { + name: "bin"; + }; + }, + 70 + ]; + }; } - ] - } + ]; + }; }, { - "name": "strategyParameters", - "type": { - "kind": "struct", - "fields": [ + name: "binArrayBitmapExtension"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ { - "name": "minBinId", - "docs": [ - "min bin id" - ], - "type": "i32" + name: "lbPair"; + type: "pubkey"; }, { - "name": "maxBinId", - "docs": [ - "max bin id" - ], - "type": "i32" + name: "positiveBinArrayBitmap"; + docs: [ + "Packed initialized bin array state for start_bin_index is positive" + ]; + type: { + array: [ + { + array: ["u64", 8]; + }, + 12 + ]; + }; }, { - "name": "strategyType", - "docs": [ - "strategy type" - ], - "type": { - "defined": { - "name": "strategyType" - } - } - }, - { - "name": "parameteres", - "docs": [ - "parameters" - ], - "type": { - "array": [ - "u8", - 64 - ] - } + name: "negativeBinArrayBitmap"; + docs: [ + "Packed initialized bin array state for start_bin_index is negative" + ]; + type: { + array: [ + { + array: ["u64", 8]; + }, + 12 + ]; + }; } - ] - } + ]; + }; }, { - "name": "liquidityOneSideParameter", - "type": { - "kind": "struct", - "fields": [ + name: "binLiquidityDistribution"; + type: { + kind: "struct"; + fields: [ { - "name": "amount", - "docs": [ - "Amount of X token or Y token to deposit" - ], - "type": "u64" + name: "binId"; + docs: ["Define the bin ID wish to deposit to."]; + type: "i32"; }, { - "name": "activeId", - "docs": [ - "Active bin that integrator observe off-chain" - ], - "type": "i32" + name: "distributionX"; + docs: [ + "DistributionX (or distributionY) is the percentages of amountX (or amountY) you want to add to each bin." + ]; + type: "u16"; }, { - "name": "maxActiveBinSlippage", - "docs": [ - "max active bin slippage allowed" - ], - "type": "i32" + name: "distributionY"; + docs: [ + "DistributionX (or distributionY) is the percentages of amountX (or amountY) you want to add to each bin." + ]; + type: "u16"; + } + ]; + }; + }, + { + name: "binLiquidityDistributionByWeight"; + type: { + kind: "struct"; + fields: [ + { + name: "binId"; + docs: ["Define the bin ID wish to deposit to."]; + type: "i32"; }, { - "name": "binLiquidityDist", - "docs": [ - "Liquidity distribution to each bins" - ], - "type": { - "vec": { - "defined": { - "name": "binLiquidityDistributionByWeight" - } - } - } + name: "weight"; + docs: ["weight of liquidity distributed for this bin id"]; + type: "u16"; } - ] - } + ]; + }; }, { - "name": "binLiquidityDistributionByWeight", - "type": { - "kind": "struct", - "fields": [ + name: "binLiquidityReduction"; + type: { + kind: "struct"; + fields: [ { - "name": "binId", - "docs": [ - "Define the bin ID wish to deposit to." - ], - "type": "i32" + name: "binId"; + type: "i32"; }, { - "name": "weight", - "docs": [ - "weight of liquidity distributed for this bin id" - ], - "type": "u16" + name: "bpsToRemove"; + type: "u16"; } - ] - } + ]; + }; }, { - "name": "liquidityParameterByWeight", - "type": { - "kind": "struct", - "fields": [ + name: "claimFee"; + type: { + kind: "struct"; + fields: [ { - "name": "amountX", - "docs": [ - "Amount of X token to deposit" - ], - "type": "u64" + name: "lbPair"; + type: "pubkey"; }, { - "name": "amountY", - "docs": [ - "Amount of Y token to deposit" - ], - "type": "u64" + name: "position"; + type: "pubkey"; }, { - "name": "activeId", - "docs": [ - "Active bin that integrator observe off-chain" - ], - "type": "i32" + name: "owner"; + type: "pubkey"; }, { - "name": "maxActiveBinSlippage", - "docs": [ - "max active bin slippage allowed" - ], - "type": "i32" + name: "feeX"; + type: "u64"; }, { - "name": "binLiquidityDist", - "docs": [ - "Liquidity distribution to each bins" - ], - "type": { - "vec": { - "defined": { - "name": "binLiquidityDistributionByWeight" - } - } - } + name: "feeY"; + type: "u64"; } - ] - } + ]; + }; }, { - "name": "addLiquiditySingleSidePreciseParameter", - "type": { - "kind": "struct", - "fields": [ + name: "claimFee2"; + type: { + kind: "struct"; + fields: [ { - "name": "bins", - "type": { - "vec": { - "defined": { - "name": "compressedBinDepositAmount" - } - } - } + name: "lbPair"; + type: "pubkey"; + }, + { + name: "position"; + type: "pubkey"; + }, + { + name: "owner"; + type: "pubkey"; }, { - "name": "decompressMultiplier", - "type": "u64" + name: "feeX"; + type: "u64"; + }, + { + name: "feeY"; + type: "u64"; + }, + { + name: "activeBinId"; + type: "i32"; + } + ]; + }; + }, + { + 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": "compressedBinDepositAmount", - "type": { - "kind": "struct", - "fields": [ + name: "claimReward"; + type: { + kind: "struct"; + fields: [ + { + name: "lbPair"; + type: "pubkey"; + }, + { + name: "position"; + type: "pubkey"; + }, + { + name: "owner"; + type: "pubkey"; + }, { - "name": "binId", - "type": "i32" + name: "rewardIndex"; + type: "u64"; }, { - "name": "amount", - "type": "u32" + name: "totalReward"; + type: "u64"; } - ] - } + ]; + }; }, { - "name": "binLiquidityDistribution", - "type": { - "kind": "struct", - "fields": [ + name: "claimReward2"; + type: { + kind: "struct"; + fields: [ { - "name": "binId", - "docs": [ - "Define the bin ID wish to deposit to." - ], - "type": "i32" + name: "lbPair"; + type: "pubkey"; }, { - "name": "distributionX", - "docs": [ - "DistributionX (or distributionY) is the percentages of amountX (or amountY) you want to add to each bin." - ], - "type": "u16" + name: "position"; + type: "pubkey"; }, { - "name": "distributionY", - "docs": [ - "DistributionX (or distributionY) is the percentages of amountX (or amountY) you want to add to each bin." - ], - "type": "u16" - } - ] - } - }, - { - "name": "liquidityParameter", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amountX", - "docs": [ - "Amount of X token to deposit" - ], - "type": "u64" - }, - { - "name": "amountY", - "docs": [ - "Amount of Y token to deposit" - ], - "type": "u64" - }, - { - "name": "binLiquidityDist", - "docs": [ - "Liquidity distribution to each bins" - ], - "type": { - "vec": { - "defined": { - "name": "binLiquidityDistribution" - } - } - } + name: "owner"; + type: "pubkey"; + }, + { + name: "rewardIndex"; + type: "u64"; + }, + { + name: "totalReward"; + type: "u64"; + }, + { + name: "activeBinId"; + type: "i32"; } - ] - } + ]; + }; }, { - "name": "customizableParams", - "type": { - "kind": "struct", - "fields": [ + name: "compositionFee"; + type: { + kind: "struct"; + fields: [ { - "name": "activeId", - "docs": [ - "Pool price" - ], - "type": "i32" + name: "from"; + type: "pubkey"; }, { - "name": "binStep", - "docs": [ - "Bin step" - ], - "type": "u16" + name: "binId"; + type: "i16"; }, { - "name": "baseFactor", - "docs": [ - "Base factor" - ], - "type": "u16" + name: "tokenXFeeAmount"; + type: "u64"; }, { - "name": "activationType", - "docs": [ - "Activation type. 0 = Slot, 1 = Time. Check ActivationType enum" - ], - "type": "u8" + name: "tokenYFeeAmount"; + type: "u64"; }, { - "name": "hasAlphaVault", - "docs": [ - "Whether the pool has an alpha vault" - ], - "type": "bool" + name: "protocolTokenXFeeAmount"; + type: "u64"; }, { - "name": "activationPoint", - "docs": [ - "Decide when does the pool start trade. None = Now" - ], - "type": { - "option": "u64" - } + name: "protocolTokenYFeeAmount"; + type: "u64"; + } + ]; + }; + }, + { + name: "compressedBinDepositAmount"; + type: { + kind: "struct"; + fields: [ + { + name: "binId"; + type: "i32"; }, { - "name": "creatorPoolOnOffControl", - "docs": [ - "Pool creator have permission to enable/disable pool with restricted program validation. Only applicable for customizable permissionless pool." - ], - "type": "bool" - }, - { - "name": "baseFeePowerFactor", - "docs": [ - "Base fee power factor" - ], - "type": "u8" - }, - { - "name": "padding", - "docs": [ - "Padding, for future use" - ], - "type": { - "array": [ - "u8", - 62 - ] - } + name: "amount"; + type: "u32"; } - ] - } + ]; + }; }, { - "name": "initPermissionPairIx", - "type": { - "kind": "struct", - "fields": [ + name: "customizableParams"; + type: { + kind: "struct"; + fields: [ { - "name": "activeId", - "type": "i32" + name: "activeId"; + docs: ["Pool price"]; + type: "i32"; }, { - "name": "binStep", - "type": "u16" + name: "binStep"; + docs: ["Bin step"]; + type: "u16"; }, { - "name": "baseFactor", - "type": "u16" + name: "baseFactor"; + docs: ["Base factor"]; + type: "u16"; }, { - "name": "baseFeePowerFactor", - "type": "u8" + name: "activationType"; + docs: [ + "Activation type. 0 = Slot, 1 = Time. Check ActivationType enum" + ]; + type: "u8"; }, { - "name": "activationType", - "type": "u8" + name: "hasAlphaVault"; + docs: ["Whether the pool has an alpha vault"]; + type: "bool"; + }, + { + name: "activationPoint"; + docs: ["Decide when does the pool start trade. None = Now"]; + type: { + option: "u64"; + }; + }, + { + name: "creatorPoolOnOffControl"; + docs: [ + "Pool creator have permission to enable/disable pool with restricted program validation. Only applicable for customizable permissionless pool." + ]; + type: "bool"; }, { - "name": "protocolShare", - "type": "u16" + name: "baseFeePowerFactor"; + docs: ["Base fee power factor"]; + type: "u8"; + }, + { + name: "padding"; + docs: ["Padding, for future use"]; + type: { + array: ["u8", 62]; + }; } - ] - } + ]; + }; }, { - "name": "addLiquiditySingleSidePreciseParameter2", - "type": { - "kind": "struct", - "fields": [ + name: "decreasePositionLength"; + type: { + kind: "struct"; + fields: [ { - "name": "bins", - "type": { - "vec": { - "defined": { - "name": "compressedBinDepositAmount" - } - } - } + name: "lbPair"; + type: "pubkey"; + }, + { + name: "position"; + type: "pubkey"; }, { - "name": "decompressMultiplier", - "type": "u64" + name: "owner"; + type: "pubkey"; }, { - "name": "maxAmount", - "type": "u64" + name: "lengthToRemove"; + type: "u16"; + }, + { + name: "side"; + type: "u8"; } - ] - } + ]; + }; }, { - "name": "compressedBinDepositAmount2", - "type": { - "kind": "struct", - "fields": [ + name: "dummyIx"; + type: { + kind: "struct"; + fields: [ + { + name: "pairStatus"; + type: { + defined: { + name: "pairStatus"; + }; + }; + }, + { + name: "pairType"; + type: { + defined: { + name: "pairType"; + }; + }; + }, + { + name: "activationType"; + type: { + defined: { + name: "activationType"; + }; + }; + }, { - "name": "binId", - "type": "i32" + name: "tokenProgramFlag"; + type: { + defined: { + name: "tokenProgramFlags"; + }; + }; }, { - "name": "amount", - "type": "u32" + name: "resizeSide"; + type: { + defined: { + name: "resizeSide"; + }; + }; + }, + { + name: "rounding"; + type: { + defined: { + name: "rounding"; + }; + }; } - ] - } - }, - { - "name": "initializeLbPair2Params", - "type": { - "kind": "struct", - "fields": [ - { - "name": "activeId", - "docs": [ - "Pool price" - ], - "type": "i32" - }, - { - "name": "padding", - "docs": [ - "Padding, for future use" - ], - "type": { - "array": [ - "u8", - 96 - ] - } + ]; + }; + }, + { + name: "dummyZcAccount"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "positionBinData"; + type: { + defined: { + name: "positionBinData"; + }; + }; } - ] - } + ]; + }; }, { - "name": "binLiquidityReduction", - "type": { - "kind": "struct", - "fields": [ + name: "dynamicFeeParameter"; + type: { + kind: "struct"; + fields: [ + { + name: "filterPeriod"; + docs: [ + "Filter period determine high frequency trading time window." + ]; + type: "u16"; + }, + { + name: "decayPeriod"; + docs: [ + "Decay period determine when the volatile fee start decay / decrease." + ]; + type: "u16"; + }, { - "name": "binId", - "type": "i32" + name: "reductionFactor"; + docs: [ + "Reduction factor controls the volatile fee rate decrement rate." + ]; + type: "u16"; + }, + { + name: "variableFeeControl"; + docs: [ + "Used to scale the variable fee component depending on the dynamic of the market" + ]; + type: "u32"; }, { - "name": "bpsToRemove", - "type": "u16" + name: "maxVolatilityAccumulator"; + docs: [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ]; + type: "u32"; } - ] - } + ]; + }; }, { - "name": "bin", - "type": { - "kind": "struct", - "fields": [ + name: "dynamicFeeParameterUpdate"; + type: { + kind: "struct"; + fields: [ { - "name": "amountX", - "docs": [ - "Amount of token X in the bin. This already excluded protocol fees." - ], - "type": "u64" + name: "lbPair"; + type: "pubkey"; }, { - "name": "amountY", - "docs": [ - "Amount of token Y in the bin. This already excluded protocol fees." - ], - "type": "u64" + name: "filterPeriod"; + docs: [ + "Filter period determine high frequency trading time window." + ]; + type: "u16"; }, { - "name": "price", - "docs": [ - "Bin price" - ], - "type": "u128" + name: "decayPeriod"; + docs: [ + "Decay period determine when the volatile fee start decay / decrease." + ]; + type: "u16"; }, { - "name": "liquiditySupply", - "docs": [ - "Liquidities of the bin. This is the same as LP mint supply. q-number" - ], - "type": "u128" + name: "reductionFactor"; + docs: [ + "Reduction factor controls the volatile fee rate decrement rate." + ]; + type: "u16"; }, { - "name": "rewardPerTokenStored", - "docs": [ - "reward_a_per_token_stored" - ], - "type": { - "array": [ - "u128", - 2 - ] - } + name: "variableFeeControl"; + docs: [ + "Used to scale the variable fee component depending on the dynamic of the market" + ]; + type: "u32"; }, { - "name": "feeAmountXPerTokenStored", - "docs": [ - "Swap fee amount of token X per liquidity deposited." - ], - "type": "u128" + name: "maxVolatilityAccumulator"; + docs: [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ]; + type: "u32"; + } + ]; + }; + }, + { + name: "feeInfo"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "feeXPerTokenComplete"; + type: "u128"; }, { - "name": "feeAmountYPerTokenStored", - "docs": [ - "Swap fee amount of token Y per liquidity deposited." - ], - "type": "u128" + name: "feeYPerTokenComplete"; + type: "u128"; }, { - "name": "amountXIn", - "docs": [ - "Total token X swap into the bin. Only used for tracking purpose." - ], - "type": "u128" + name: "feeXPending"; + type: "u64"; }, { - "name": "amountYIn", - "docs": [ - "Total token Y swap into he bin. Only used for tracking purpose." - ], - "type": "u128" + name: "feeYPending"; + type: "u64"; } - ] - } + ]; + }; }, { - "name": "protocolFee", - "type": { - "kind": "struct", - "fields": [ + name: "feeParameterUpdate"; + type: { + kind: "struct"; + fields: [ + { + name: "lbPair"; + type: "pubkey"; + }, { - "name": "amountX", - "type": "u64" + name: "protocolShare"; + type: "u16"; }, { - "name": "amountY", - "type": "u64" + name: "baseFactor"; + type: "u16"; } - ] - } + ]; + }; }, { - "name": "rewardInfo", - "docs": [ - "Stores the state relevant for tracking liquidity mining rewards" - ], - "type": { - "kind": "struct", - "fields": [ + name: "fundReward"; + type: { + kind: "struct"; + fields: [ { - "name": "mint", - "docs": [ - "Reward token mint." - ], - "type": "pubkey" + name: "lbPair"; + type: "pubkey"; }, { - "name": "vault", - "docs": [ - "Reward vault token account." - ], - "type": "pubkey" + name: "funder"; + type: "pubkey"; }, { - "name": "funder", - "docs": [ - "Authority account that allows to fund rewards" - ], - "type": "pubkey" + name: "rewardIndex"; + type: "u64"; }, { - "name": "rewardDuration", - "docs": [ - "TODO check whether we need to store it in pool" - ], - "type": "u64" + name: "amount"; + type: "u64"; + } + ]; + }; + }, + { + name: "goToABin"; + type: { + kind: "struct"; + fields: [ + { + name: "lbPair"; + type: "pubkey"; }, { - "name": "rewardDurationEnd", - "docs": [ - "TODO check whether we need to store it in pool" - ], - "type": "u64" + name: "fromBinId"; + type: "i32"; }, { - "name": "rewardRate", - "docs": [ - "TODO check whether we need to store it in pool" - ], - "type": "u128" + name: "toBinId"; + type: "i32"; + } + ]; + }; + }, + { + name: "increaseObservation"; + type: { + kind: "struct"; + fields: [ + { + name: "oracle"; + type: "pubkey"; }, { - "name": "lastUpdateTime", - "docs": [ - "The last time reward states were updated." - ], - "type": "u64" + name: "newObservationLength"; + type: "u64"; + } + ]; + }; + }, + { + name: "increasePositionLength"; + type: { + kind: "struct"; + fields: [ + { + name: "lbPair"; + type: "pubkey"; }, { - "name": "cumulativeSecondsWithEmptyLiquidityReward", - "docs": [ - "Accumulated seconds where when farm distribute rewards, but the bin is empty. The reward will be accumulated for next reward time window." - ], - "type": "u64" + name: "position"; + type: "pubkey"; + }, + { + name: "owner"; + type: "pubkey"; + }, + { + name: "lengthToAdd"; + type: "u16"; + }, + { + name: "side"; + type: "u8"; } - ] - } + ]; + }; }, { - "name": "observation", - "type": { - "kind": "struct", - "fields": [ + name: "initPermissionPairIx"; + type: { + kind: "struct"; + fields: [ + { + name: "activeId"; + type: "i32"; + }, { - "name": "cumulativeActiveBinId", - "docs": [ - "Cumulative active bin ID" - ], - "type": "i128" + name: "binStep"; + type: "u16"; }, { - "name": "createdAt", - "docs": [ - "Observation sample created timestamp" - ], - "type": "i64" + name: "baseFactor"; + type: "u16"; }, { - "name": "lastUpdatedAt", - "docs": [ - "Observation sample last updated timestamp" - ], - "type": "i64" + name: "baseFeePowerFactor"; + type: "u8"; + }, + { + name: "activationType"; + type: "u8"; + }, + { + name: "protocolShare"; + type: "u16"; } - ] - } + ]; + }; }, { - "name": "staticParameters", - "docs": [ - "Parameter that set by the protocol" - ], - "type": { - "kind": "struct", - "fields": [ + name: "initPresetParameters2Ix"; + type: { + kind: "struct"; + fields: [ + { + name: "index"; + type: "u16"; + }, { - "name": "baseFactor", - "docs": [ + name: "binStep"; + docs: ["Bin step. Represent the price increment / decrement."]; + type: "u16"; + }, + { + name: "baseFactor"; + docs: [ "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" - ], - "type": "u16" + ]; + type: "u16"; }, { - "name": "filterPeriod", - "docs": [ + name: "filterPeriod"; + docs: [ "Filter period determine high frequency trading time window." - ], - "type": "u16" + ]; + type: "u16"; }, { - "name": "decayPeriod", - "docs": [ + name: "decayPeriod"; + docs: [ "Decay period determine when the volatile fee start decay / decrease." - ], - "type": "u16" + ]; + type: "u16"; }, { - "name": "reductionFactor", - "docs": [ + name: "reductionFactor"; + docs: [ "Reduction factor controls the volatile fee rate decrement rate." - ], - "type": "u16" + ]; + type: "u16"; }, { - "name": "variableFeeControl", - "docs": [ + name: "variableFeeControl"; + docs: [ "Used to scale the variable fee component depending on the dynamic of the market" - ], - "type": "u32" + ]; + type: "u32"; }, { - "name": "maxVolatilityAccumulator", - "docs": [ + name: "maxVolatilityAccumulator"; + docs: [ "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." - ], - "type": "u32" + ]; + type: "u32"; }, { - "name": "minBinId", - "docs": [ - "Min bin id supported by the pool based on the configured bin step." - ], - "type": "i32" + name: "protocolShare"; + docs: [ + "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + ]; + type: "u16"; }, { - "name": "maxBinId", - "docs": [ - "Max bin id supported by the pool based on the configured bin step." - ], - "type": "i32" + name: "baseFeePowerFactor"; + docs: ["Base fee power factor"]; + type: "u8"; + } + ]; + }; + }, + { + name: "initPresetParametersIx"; + type: { + kind: "struct"; + fields: [ + { + name: "binStep"; + docs: ["Bin step. Represent the price increment / decrement."]; + type: "u16"; }, { - "name": "protocolShare", - "docs": [ + name: "baseFactor"; + docs: [ + "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" + ]; + type: "u16"; + }, + { + name: "filterPeriod"; + docs: [ + "Filter period determine high frequency trading time window." + ]; + type: "u16"; + }, + { + name: "decayPeriod"; + docs: [ + "Decay period determine when the volatile fee start decay / decrease." + ]; + type: "u16"; + }, + { + name: "reductionFactor"; + docs: [ + "Reduction factor controls the volatile fee rate decrement rate." + ]; + type: "u16"; + }, + { + name: "variableFeeControl"; + docs: [ + "Used to scale the variable fee component depending on the dynamic of the market" + ]; + type: "u32"; + }, + { + name: "maxVolatilityAccumulator"; + docs: [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ]; + type: "u32"; + }, + { + name: "protocolShare"; + docs: [ "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" - }, - { - "name": "baseFeePowerFactor", - "docs": [ - "Base fee power factor" - ], - "type": "u8" - }, - { - "name": "padding", - "docs": [ - "Padding for bytemuck safe alignment" - ], - "type": { - "array": [ - "u8", - 5 - ] - } + ]; + type: "u16"; } - ] - } + ]; + }; }, { - "name": "variableParameters", - "docs": [ - "Parameters that changes based on dynamic of the market" - ], - "type": { - "kind": "struct", - "fields": [ + name: "initializeLbPair2Params"; + type: { + kind: "struct"; + fields: [ { - "name": "volatilityAccumulator", - "docs": [ - "Volatility accumulator measure the number of bin crossed since reference bin ID. Normally (without filter period taken into consideration), reference bin ID is the active bin of last swap.", - "It affects the variable fee rate" - ], - "type": "u32" + name: "activeId"; + docs: ["Pool price"]; + type: "i32"; }, { - "name": "volatilityReference", - "docs": [ - "Volatility reference is decayed volatility accumulator. It is always <= volatility_accumulator" - ], - "type": "u32" - }, - { - "name": "indexReference", - "docs": [ - "Active bin id of last swap." - ], - "type": "i32" - }, - { - "name": "padding", - "docs": [ - "Padding for bytemuck safe alignment" - ], - "type": { - "array": [ - "u8", - 4 - ] - } - }, - { - "name": "lastUpdateTimestamp", - "docs": [ - "Last timestamp the variable parameters was updated" - ], - "type": "i64" - }, - { - "name": "padding1", - "docs": [ - "Padding for bytemuck safe alignment" - ], - "type": { - "array": [ - "u8", - 8 - ] - } + name: "padding"; + docs: ["Padding, for future use"]; + type: { + array: ["u8", 96]; + }; } - ] - } + ]; + }; }, { - "name": "feeInfo", - "type": { - "kind": "struct", - "fields": [ + name: "initializeReward"; + type: { + kind: "struct"; + fields: [ + { + name: "lbPair"; + type: "pubkey"; + }, + { + name: "rewardMint"; + type: "pubkey"; + }, + { + name: "funder"; + type: "pubkey"; + }, + { + name: "rewardIndex"; + type: "u64"; + }, + { + name: "rewardDuration"; + type: "u64"; + } + ]; + }; + }, + { + name: "lbPair"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "parameters"; + type: { + defined: { + name: "staticParameters"; + }; + }; + }, + { + name: "vParameters"; + type: { + defined: { + name: "variableParameters"; + }; + }; + }, + { + name: "bumpSeed"; + type: { + array: ["u8", 1]; + }; + }, + { + name: "binStepSeed"; + docs: ["Bin step signer seed"]; + type: { + array: ["u8", 2]; + }; + }, + { + name: "pairType"; + docs: ["Type of the pair"]; + type: "u8"; + }, + { + name: "activeId"; + docs: ["Active bin id"]; + type: "i32"; + }, + { + name: "binStep"; + docs: ["Bin step. Represent the price increment / decrement."]; + type: "u16"; + }, + { + name: "status"; + docs: ["Status of the pair. Check PairStatus enum."]; + type: "u8"; + }, + { + name: "requireBaseFactorSeed"; + docs: ["Require base factor seed"]; + type: "u8"; + }, + { + name: "baseFactorSeed"; + docs: ["Base factor seed"]; + type: { + array: ["u8", 2]; + }; + }, + { + name: "activationType"; + docs: ["Activation type"]; + type: "u8"; + }, + { + name: "creatorPoolOnOffControl"; + docs: [ + "Allow pool creator to enable/disable pool with restricted validation. Only applicable for customizable permissionless pair type." + ]; + type: "u8"; + }, + { + name: "tokenXMint"; + docs: ["Token X mint"]; + type: "pubkey"; + }, { - "name": "feeXPerTokenComplete", - "type": "u128" + name: "tokenYMint"; + docs: ["Token Y mint"]; + type: "pubkey"; }, { - "name": "feeYPerTokenComplete", - "type": "u128" + name: "reserveX"; + docs: ["LB token X vault"]; + type: "pubkey"; }, { - "name": "feeXPending", - "type": "u64" + name: "reserveY"; + docs: ["LB token Y vault"]; + type: "pubkey"; }, { - "name": "feeYPending", - "type": "u64" - } - ] - } - }, - { - "name": "userRewardInfo", - "type": { - "kind": "struct", - "fields": [ + name: "protocolFee"; + docs: ["Uncollected protocol fee"]; + type: { + defined: { + name: "protocolFee"; + }; + }; + }, { - "name": "rewardPerTokenCompletes", - "type": { - "array": [ - "u128", - 2 - ] - } + name: "padding1"; + docs: [ + "_padding_1, previous Fee owner, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + ]; + type: { + array: ["u8", 32]; + }; }, { - "name": "rewardPendings", - "type": { - "array": [ - "u64", + name: "rewardInfos"; + docs: ["Farming reward information"]; + type: { + array: [ + { + defined: { + name: "rewardInfo"; + }; + }, 2 - ] - } - } - ] - } - }, - { - "name": "remainingAccountsSlice", - "type": { - "kind": "struct", - "fields": [ + ]; + }; + }, { - "name": "accountsType", - "type": { - "defined": { - "name": "accountsType" - } - } + name: "oracle"; + docs: ["Oracle pubkey"]; + type: "pubkey"; }, { - "name": "length", - "type": "u8" - } - ] - } - }, - { - "name": "remainingAccountsInfo", - "type": { - "kind": "struct", - "fields": [ + name: "binArrayBitmap"; + docs: ["Packed initialized bin array state"]; + type: { + array: ["u64", 16]; + }; + }, { - "name": "slices", - "type": { - "vec": { - "defined": { - "name": "remainingAccountsSlice" - } - } - } - } - ] - } - }, - { - "name": "strategyType", - "type": { - "kind": "enum", - "variants": [ + name: "lastUpdatedAt"; + docs: ["Last time the pool fee parameter was updated"]; + type: "i64"; + }, { - "name": "spotOneSide" + name: "padding2"; + docs: [ + "_padding_2, previous whitelisted_wallet, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + ]; + type: { + array: ["u8", 32]; + }; }, { - "name": "curveOneSide" + name: "preActivationSwapAddress"; + docs: [ + "Address allowed to swap when the current point is greater than or equal to the pre-activation point. The pre-activation point is calculated as `activation_point - pre_activation_duration`." + ]; + type: "pubkey"; }, { - "name": "bidAskOneSide" + name: "baseKey"; + docs: ["Base keypair. Only required for permission pair"]; + type: "pubkey"; }, { - "name": "spotBalanced" + name: "activationPoint"; + docs: [ + "Time point to enable the pair. Only applicable for permission pair." + ]; + type: "u64"; }, { - "name": "curveBalanced" + name: "preActivationDuration"; + docs: [ + "Duration before activation activation_point. Used to calculate pre-activation time point for pre_activation_swap_address" + ]; + type: "u64"; }, { - "name": "bidAskBalanced" + name: "padding3"; + docs: [ + "_padding 3 is reclaimed free space from swap_cap_deactivate_point and swap_cap_amount before, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + ]; + type: { + array: ["u8", 8]; + }; }, { - "name": "spotImBalanced" + name: "padding4"; + docs: [ + "_padding_4, previous lock_duration, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + ]; + type: "u64"; }, { - "name": "curveImBalanced" + name: "creator"; + docs: ["Pool creator"]; + type: "pubkey"; }, { - "name": "bidAskImBalanced" - } - ] - } - }, - { - "name": "rounding", - "type": { - "kind": "enum", - "variants": [ + name: "tokenMintXProgramFlag"; + docs: ["tokenMintXProgramFlag"]; + type: "u8"; + }, { - "name": "up" + name: "tokenMintYProgramFlag"; + docs: ["tokenMintYProgramFlag"]; + type: "u8"; }, { - "name": "down" + name: "reserved"; + docs: ["Reserved space for future use"]; + type: { + array: ["u8", 22]; + }; } - ] - } + ]; + }; }, { - "name": "activationType", - "docs": [ - "Type of the activation" - ], - "type": { - "kind": "enum", - "variants": [ + name: "lbPairCreate"; + type: { + kind: "struct"; + fields: [ { - "name": "slot" + name: "lbPair"; + type: "pubkey"; }, { - "name": "timestamp" - } - ] - } - }, - { - "name": "layoutVersion", - "docs": [ - "Layout version" - ], - "type": { - "kind": "enum", - "variants": [ + name: "binStep"; + type: "u16"; + }, { - "name": "v0" + name: "tokenX"; + type: "pubkey"; }, { - "name": "v1" + name: "tokenY"; + type: "pubkey"; } - ] - } + ]; + }; }, { - "name": "pairType", - "docs": [ - "Type of the Pair. 0 = Permissionless, 1 = Permission, 2 = CustomizablePermissionless. Putting 0 as permissionless for backward compatibility." - ], - "type": { - "kind": "enum", - "variants": [ + name: "liquidityOneSideParameter"; + type: { + kind: "struct"; + fields: [ { - "name": "permissionless" + name: "amount"; + docs: ["Amount of X token or Y token to deposit"]; + type: "u64"; }, { - "name": "permission" + name: "activeId"; + docs: ["Active bin that integrator observe off-chain"]; + type: "i32"; }, { - "name": "customizablePermissionless" + name: "maxActiveBinSlippage"; + docs: ["max active bin slippage allowed"]; + type: "i32"; }, { - "name": "permissionlessV2" + name: "binLiquidityDist"; + docs: ["Liquidity distribution to each bins"]; + type: { + vec: { + defined: { + name: "binLiquidityDistributionByWeight"; + }; + }; + }; } - ] - } + ]; + }; }, { - "name": "pairStatus", - "docs": [ - "Pair status. 0 = Enabled, 1 = Disabled. Putting 0 as enabled for backward compatibility." - ], - "type": { - "kind": "enum", - "variants": [ + name: "liquidityParameter"; + type: { + kind: "struct"; + fields: [ { - "name": "enabled" + name: "amountX"; + docs: ["Amount of X token to deposit"]; + type: "u64"; }, { - "name": "disabled" - } - ] - } - }, - { - "name": "tokenProgramFlags", - "type": { - "kind": "enum", - "variants": [ - { - "name": "tokenProgram" + name: "amountY"; + docs: ["Amount of Y token to deposit"]; + type: "u64"; }, { - "name": "tokenProgram2022" + name: "binLiquidityDist"; + docs: ["Liquidity distribution to each bins"]; + type: { + vec: { + defined: { + name: "binLiquidityDistribution"; + }; + }; + }; } - ] - } + ]; + }; }, { - "name": "accountsType", - "type": { - "kind": "enum", - "variants": [ + name: "liquidityParameterByStrategy"; + type: { + kind: "struct"; + fields: [ { - "name": "transferHookX" + name: "amountX"; + docs: ["Amount of X token to deposit"]; + type: "u64"; }, { - "name": "transferHookY" + name: "amountY"; + docs: ["Amount of Y token to deposit"]; + type: "u64"; }, { - "name": "transferHookReward" - } - ] - } - }, - { - "name": "binArrayBitmapExtension", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lbPair", - "type": "pubkey" + name: "activeId"; + docs: ["Active bin that integrator observe off-chain"]; + type: "i32"; }, { - "name": "positiveBinArrayBitmap", - "docs": [ - "Packed initialized bin array state for start_bin_index is positive" - ], - "type": { - "array": [ - { - "array": [ - "u64", - 8 - ] - }, - 12 - ] - } + name: "maxActiveBinSlippage"; + docs: ["max active bin slippage allowed"]; + type: "i32"; }, { - "name": "negativeBinArrayBitmap", - "docs": [ - "Packed initialized bin array state for start_bin_index is negative" - ], - "type": { - "array": [ - { - "array": [ - "u64", - 8 - ] - }, - 12 - ] - } + name: "strategyParameters"; + docs: ["strategy parameters"]; + type: { + defined: { + name: "strategyParameters"; + }; + }; } - ] - } + ]; + }; }, { - "name": "binArray", - "docs": [ - "An account to contain a range of bin. For example: Bin 100 <-> 200.", - "For example:", - "BinArray index: 0 contains bin 0 <-> 599", - "index: 2 contains bin 600 <-> 1199, ..." - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "index", - "type": "i64" - }, + name: "liquidityParameterByStrategyOneSide"; + type: { + kind: "struct"; + fields: [ { - "name": "version", - "docs": [ - "Version of binArray" - ], - "type": "u8" + name: "amount"; + docs: ["Amount of X token or Y token to deposit"]; + type: "u64"; }, { - "name": "padding", - "type": { - "array": [ - "u8", - 7 - ] - } + name: "activeId"; + docs: ["Active bin that integrator observe off-chain"]; + type: "i32"; }, { - "name": "lbPair", - "type": "pubkey" + name: "maxActiveBinSlippage"; + docs: ["max active bin slippage allowed"]; + type: "i32"; }, { - "name": "bins", - "type": { - "array": [ - { - "defined": { - "name": "bin" - } - }, - 70 - ] - } + name: "strategyParameters"; + docs: ["strategy parameters"]; + type: { + defined: { + name: "strategyParameters"; + }; + }; } - ] - } - }, - { - "name": "claimFeeOperator", - "docs": [ - "Parameter that set by the protocol" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "operator", - "docs": [ - "operator" - ], - "type": "pubkey" - }, - { - "name": "padding", - "docs": [ - "Reserve" - ], - "type": { - "array": [ - "u8", - 128 - ] - } - } - ] - } + ]; + }; }, { - "name": "lbPair", - "type": { - "kind": "struct", - "fields": [ + name: "liquidityParameterByWeight"; + type: { + kind: "struct"; + fields: [ { - "name": "parameters", - "type": { - "defined": { - "name": "staticParameters" - } - } + name: "amountX"; + docs: ["Amount of X token to deposit"]; + type: "u64"; }, { - "name": "vParameters", - "type": { - "defined": { - "name": "variableParameters" - } - } + name: "amountY"; + docs: ["Amount of Y token to deposit"]; + type: "u64"; }, { - "name": "bumpSeed", - "type": { - "array": [ - "u8", - 1 - ] - } + name: "activeId"; + docs: ["Active bin that integrator observe off-chain"]; + type: "i32"; }, { - "name": "binStepSeed", - "docs": [ - "Bin step signer seed" - ], - "type": { - "array": [ - "u8", - 2 - ] - } + name: "maxActiveBinSlippage"; + docs: ["max active bin slippage allowed"]; + type: "i32"; }, { - "name": "pairType", - "docs": [ - "Type of the pair" - ], - "type": "u8" - }, + name: "binLiquidityDist"; + docs: ["Liquidity distribution to each bins"]; + type: { + vec: { + defined: { + name: "binLiquidityDistributionByWeight"; + }; + }; + }; + } + ]; + }; + }, + { + name: "oracle"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ { - "name": "activeId", - "docs": [ - "Active bin id" - ], - "type": "i32" + name: "idx"; + docs: ["Index of latest observation"]; + type: "u64"; }, { - "name": "binStep", - "docs": [ - "Bin step. Represent the price increment / decrement." - ], - "type": "u16" + name: "activeSize"; + docs: [ + "Size of active sample. Active sample is initialized observation." + ]; + type: "u64"; }, { - "name": "status", - "docs": [ - "Status of the pair. Check PairStatus enum." - ], - "type": "u8" - }, + name: "length"; + docs: ["Number of observations"]; + type: "u64"; + } + ]; + }; + }, + { + name: "pairStatus"; + docs: [ + "Pair status. 0 = Enabled, 1 = Disabled. Putting 0 as enabled for backward compatibility." + ]; + repr: { + kind: "rust"; + }; + type: { + kind: "enum"; + variants: [ { - "name": "requireBaseFactorSeed", - "docs": [ - "Require base factor seed" - ], - "type": "u8" + name: "enabled"; }, { - "name": "baseFactorSeed", - "docs": [ - "Base factor seed" - ], - "type": { - "array": [ - "u8", - 2 - ] - } - }, + name: "disabled"; + } + ]; + }; + }, + { + name: "pairType"; + docs: [ + "Type of the Pair. 0 = Permissionless, 1 = Permission, 2 = CustomizablePermissionless. Putting 0 as permissionless for backward compatibility." + ]; + repr: { + kind: "rust"; + }; + type: { + kind: "enum"; + variants: [ { - "name": "activationType", - "docs": [ - "Activation type" - ], - "type": "u8" + name: "permissionless"; }, { - "name": "creatorPoolOnOffControl", - "docs": [ - "Allow pool creator to enable/disable pool with restricted validation. Only applicable for customizable permissionless pair type." - ], - "type": "u8" + name: "permission"; }, { - "name": "tokenXMint", - "docs": [ - "Token X mint" - ], - "type": "pubkey" + name: "customizablePermissionless"; }, { - "name": "tokenYMint", - "docs": [ - "Token Y mint" - ], - "type": "pubkey" - }, + name: "permissionlessV2"; + } + ]; + }; + }, + { + name: "position"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ { - "name": "reserveX", - "docs": [ - "LB token X vault" - ], - "type": "pubkey" + name: "lbPair"; + docs: ["The LB pair of this position"]; + type: "pubkey"; }, { - "name": "reserveY", - "docs": [ - "LB token Y vault" - ], - "type": "pubkey" + name: "owner"; + docs: [ + "Owner of the position. Client rely on this to to fetch their positions." + ]; + type: "pubkey"; }, { - "name": "protocolFee", - "docs": [ - "Uncollected protocol fee" - ], - "type": { - "defined": { - "name": "protocolFee" - } - } + name: "liquidityShares"; + docs: [ + "Liquidity shares of this position in bins (lower_bin_id <-> upper_bin_id). This is the same as LP concept." + ]; + type: { + array: ["u64", 70]; + }; }, { - "name": "padding1", - "docs": [ - "_padding_1, previous Fee owner, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "rewardInfos", - "docs": [ - "Farming reward information" - ], - "type": { - "array": [ + name: "rewardInfos"; + docs: ["Farming reward information"]; + type: { + array: [ { - "defined": { - "name": "rewardInfo" - } + defined: { + name: "userRewardInfo"; + }; }, - 2 - ] - } - }, - { - "name": "oracle", - "docs": [ - "Oracle pubkey" - ], - "type": "pubkey" + 70 + ]; + }; }, { - "name": "binArrayBitmap", - "docs": [ - "Packed initialized bin array state" - ], - "type": { - "array": [ - "u64", - 16 - ] - } + name: "feeInfos"; + docs: ["Swap fee to claim information"]; + type: { + array: [ + { + defined: { + name: "feeInfo"; + }; + }, + 70 + ]; + }; }, { - "name": "lastUpdatedAt", - "docs": [ - "Last time the pool fee parameter was updated" - ], - "type": "i64" + name: "lowerBinId"; + docs: ["Lower bin ID"]; + type: "i32"; }, { - "name": "padding2", - "docs": [ - "_padding_2, previous whitelisted_wallet, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" - ], - "type": { - "array": [ - "u8", - 32 - ] - } + name: "upperBinId"; + docs: ["Upper bin ID"]; + type: "i32"; }, { - "name": "preActivationSwapAddress", - "docs": [ - "Address allowed to swap when the current point is greater than or equal to the pre-activation point. The pre-activation point is calculated as `activation_point - pre_activation_duration`." - ], - "type": "pubkey" + name: "lastUpdatedAt"; + docs: ["Last updated timestamp"]; + type: "i64"; }, { - "name": "baseKey", - "docs": [ - "Base keypair. Only required for permission pair" - ], - "type": "pubkey" + name: "totalClaimedFeeXAmount"; + docs: ["Total claimed token fee X"]; + type: "u64"; }, { - "name": "activationPoint", - "docs": [ - "Time point to enable the pair. Only applicable for permission pair." - ], - "type": "u64" + name: "totalClaimedFeeYAmount"; + docs: ["Total claimed token fee Y"]; + type: "u64"; }, { - "name": "preActivationDuration", - "docs": [ - "Duration before activation activation_point. Used to calculate pre-activation time point for pre_activation_swap_address" - ], - "type": "u64" + name: "totalClaimedRewards"; + docs: ["Total claimed rewards"]; + type: { + array: ["u64", 2]; + }; }, { - "name": "padding3", - "docs": [ - "_padding 3 is reclaimed free space from swap_cap_deactivate_point and swap_cap_amount before, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" - ], - "type": { - "array": [ - "u8", - 8 - ] - } - }, + name: "reserved"; + docs: ["Reserved space for future use"]; + type: { + array: ["u8", 160]; + }; + } + ]; + }; + }, + { + name: "positionBinData"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ { - "name": "padding4", - "docs": [ - "_padding_4, previous lock_duration, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" - ], - "type": "u64" + name: "liquidityShare"; + type: "u128"; }, { - "name": "creator", - "docs": [ - "Pool creator" - ], - "type": "pubkey" + name: "rewardInfo"; + type: { + defined: { + name: "userRewardInfo"; + }; + }; }, { - "name": "tokenMintXProgramFlag", - "docs": [ - "tokenMintXProgramFlag" - ], - "type": "u8" - }, + name: "feeInfo"; + type: { + defined: { + name: "feeInfo"; + }; + }; + } + ]; + }; + }, + { + name: "positionClose"; + type: { + kind: "struct"; + fields: [ { - "name": "tokenMintYProgramFlag", - "docs": [ - "tokenMintYProgramFlag" - ], - "type": "u8" + name: "position"; + type: "pubkey"; }, { - "name": "reserved", - "docs": [ - "Reserved space for future use" - ], - "type": { - "array": [ - "u8", - 22 - ] - } + name: "owner"; + type: "pubkey"; } - ] - } + ]; + }; }, { - "name": "oracle", - "type": { - "kind": "struct", - "fields": [ + name: "positionCreate"; + type: { + kind: "struct"; + fields: [ { - "name": "idx", - "docs": [ - "Index of latest observation" - ], - "type": "u64" + name: "lbPair"; + type: "pubkey"; }, { - "name": "activeSize", - "docs": [ - "Size of active sample. Active sample is initialized observation." - ], - "type": "u64" + name: "position"; + type: "pubkey"; }, { - "name": "length", - "docs": [ - "Number of observations" - ], - "type": "u64" + name: "owner"; + type: "pubkey"; } - ] - } + ]; + }; }, { - "name": "position", - "type": { - "kind": "struct", - "fields": [ + name: "positionV2"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ { - "name": "lbPair", - "docs": [ - "The LB pair of this position" - ], - "type": "pubkey" + name: "lbPair"; + docs: ["The LB pair of this position"]; + type: "pubkey"; }, { - "name": "owner", - "docs": [ + name: "owner"; + docs: [ "Owner of the position. Client rely on this to to fetch their positions." - ], - "type": "pubkey" + ]; + type: "pubkey"; }, { - "name": "liquidityShares", - "docs": [ + name: "liquidityShares"; + docs: [ "Liquidity shares of this position in bins (lower_bin_id <-> upper_bin_id). This is the same as LP concept." - ], - "type": { - "array": [ - "u64", - 70 - ] - } + ]; + type: { + array: ["u128", 70]; + }; }, { - "name": "rewardInfos", - "docs": [ - "Farming reward information" - ], - "type": { - "array": [ + name: "rewardInfos"; + docs: ["Farming reward information"]; + type: { + array: [ { - "defined": { - "name": "userRewardInfo" - } + defined: { + name: "userRewardInfo"; + }; }, 70 - ] - } + ]; + }; }, { - "name": "feeInfos", - "docs": [ - "Swap fee to claim information" - ], - "type": { - "array": [ + name: "feeInfos"; + docs: ["Swap fee to claim information"]; + type: { + array: [ { - "defined": { - "name": "feeInfo" - } + defined: { + name: "feeInfo"; + }; }, 70 - ] - } + ]; + }; }, { - "name": "lowerBinId", - "docs": [ - "Lower bin ID" - ], - "type": "i32" + name: "lowerBinId"; + docs: ["Lower bin ID"]; + type: "i32"; }, { - "name": "upperBinId", - "docs": [ - "Upper bin ID" - ], - "type": "i32" + name: "upperBinId"; + docs: ["Upper bin ID"]; + type: "i32"; }, { - "name": "lastUpdatedAt", - "docs": [ - "Last updated timestamp" - ], - "type": "i64" + name: "lastUpdatedAt"; + docs: ["Last updated timestamp"]; + type: "i64"; }, { - "name": "totalClaimedFeeXAmount", - "docs": [ - "Total claimed token fee X" - ], - "type": "u64" + name: "totalClaimedFeeXAmount"; + docs: ["Total claimed token fee X"]; + type: "u64"; }, { - "name": "totalClaimedFeeYAmount", - "docs": [ - "Total claimed token fee Y" - ], - "type": "u64" + name: "totalClaimedFeeYAmount"; + docs: ["Total claimed token fee Y"]; + type: "u64"; }, { - "name": "totalClaimedRewards", - "docs": [ - "Total claimed rewards" - ], - "type": { - "array": [ - "u64", - 2 - ] - } - }, - { - "name": "reserved", - "docs": [ - "Reserved space for future use" - ], - "type": { - "array": [ - "u8", - 160 - ] - } - } - ] - } - }, - { - "name": "positionV2", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lbPair", - "docs": [ - "The LB pair of this position" - ], - "type": "pubkey" + name: "totalClaimedRewards"; + docs: ["Total claimed rewards"]; + type: { + array: ["u64", 2]; + }; }, { - "name": "owner", - "docs": [ - "Owner of the position. Client rely on this to to fetch their positions." - ], - "type": "pubkey" + name: "operator"; + docs: ["Operator of position"]; + type: "pubkey"; }, { - "name": "liquidityShares", - "docs": [ - "Liquidity shares of this position in bins (lower_bin_id <-> upper_bin_id). This is the same as LP concept." - ], - "type": { - "array": [ - "u128", - 70 - ] - } + name: "lockReleasePoint"; + docs: ["Time point which the locked liquidity can be withdraw"]; + type: "u64"; }, { - "name": "rewardInfos", - "docs": [ - "Farming reward information" - ], - "type": { - "array": [ - { - "defined": { - "name": "userRewardInfo" - } - }, - 70 - ] - } + name: "padding0"; + docs: [ + "_padding_0, previous subjected_to_bootstrap_liquidity_locking, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" + ]; + type: "u8"; }, { - "name": "feeInfos", - "docs": [ - "Swap fee to claim information" - ], - "type": { - "array": [ - { - "defined": { - "name": "feeInfo" - } - }, - 70 - ] - } + name: "feeOwner"; + docs: [ + "Address is able to claim fee in this position, only valid for bootstrap_liquidity_position" + ]; + type: "pubkey"; }, { - "name": "lowerBinId", - "docs": [ - "Lower bin ID" - ], - "type": "i32" + name: "reserved"; + docs: ["Reserved space for future use"]; + type: { + array: ["u8", 87]; + }; + } + ]; + }; + }, + { + name: "presetParameter"; + type: { + kind: "struct"; + fields: [ + { + name: "binStep"; + docs: ["Bin step. Represent the price increment / decrement."]; + type: "u16"; }, { - "name": "upperBinId", - "docs": [ - "Upper bin ID" - ], - "type": "i32" + name: "baseFactor"; + docs: [ + "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" + ]; + type: "u16"; }, { - "name": "lastUpdatedAt", - "docs": [ - "Last updated timestamp" - ], - "type": "i64" + name: "filterPeriod"; + docs: [ + "Filter period determine high frequency trading time window." + ]; + type: "u16"; }, { - "name": "totalClaimedFeeXAmount", - "docs": [ - "Total claimed token fee X" - ], - "type": "u64" + name: "decayPeriod"; + docs: [ + "Decay period determine when the volatile fee start decay / decrease." + ]; + type: "u16"; }, { - "name": "totalClaimedFeeYAmount", - "docs": [ - "Total claimed token fee Y" - ], - "type": "u64" + name: "reductionFactor"; + docs: [ + "Reduction factor controls the volatile fee rate decrement rate." + ]; + type: "u16"; }, { - "name": "totalClaimedRewards", - "docs": [ - "Total claimed rewards" - ], - "type": { - "array": [ - "u64", - 2 - ] - } + name: "variableFeeControl"; + docs: [ + "Used to scale the variable fee component depending on the dynamic of the market" + ]; + type: "u32"; }, { - "name": "operator", - "docs": [ - "Operator of position" - ], - "type": "pubkey" + name: "maxVolatilityAccumulator"; + docs: [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ]; + type: "u32"; }, { - "name": "lockReleasePoint", - "docs": [ - "Time point which the locked liquidity can be withdraw" - ], - "type": "u64" + name: "minBinId"; + docs: [ + "Min bin id supported by the pool based on the configured bin step." + ]; + type: "i32"; }, { - "name": "padding0", - "docs": [ - "_padding_0, previous subjected_to_bootstrap_liquidity_locking, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!" - ], - "type": "u8" + name: "maxBinId"; + docs: [ + "Max bin id supported by the pool based on the configured bin step." + ]; + type: "i32"; }, { - "name": "feeOwner", - "docs": [ - "Address is able to claim fee in this position, only valid for bootstrap_liquidity_position" - ], - "type": "pubkey" - }, - { - "name": "reserved", - "docs": [ - "Reserved space for future use" - ], - "type": { - "array": [ - "u8", - 87 - ] - } + name: "protocolShare"; + docs: [ + "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + ]; + type: "u16"; } - ] - } + ]; + }; }, { - "name": "presetParameter2", - "type": { - "kind": "struct", - "fields": [ + name: "presetParameter2"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ { - "name": "binStep", - "docs": [ - "Bin step. Represent the price increment / decrement." - ], - "type": "u16" + name: "binStep"; + docs: ["Bin step. Represent the price increment / decrement."]; + type: "u16"; }, { - "name": "baseFactor", - "docs": [ + name: "baseFactor"; + docs: [ "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" - ], - "type": "u16" + ]; + type: "u16"; }, { - "name": "filterPeriod", - "docs": [ + name: "filterPeriod"; + docs: [ "Filter period determine high frequency trading time window." - ], - "type": "u16" + ]; + type: "u16"; }, { - "name": "decayPeriod", - "docs": [ + name: "decayPeriod"; + docs: [ "Decay period determine when the volatile fee start decay / decrease." - ], - "type": "u16" + ]; + type: "u16"; }, { - "name": "variableFeeControl", - "docs": [ + name: "variableFeeControl"; + docs: [ "Used to scale the variable fee component depending on the dynamic of the market" - ], - "type": "u32" + ]; + type: "u32"; }, { - "name": "maxVolatilityAccumulator", - "docs": [ + name: "maxVolatilityAccumulator"; + docs: [ "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." - ], - "type": "u32" + ]; + type: "u32"; }, { - "name": "reductionFactor", - "docs": [ + name: "reductionFactor"; + docs: [ "Reduction factor controls the volatile fee rate decrement rate." - ], - "type": "u16" + ]; + type: "u16"; }, { - "name": "protocolShare", - "docs": [ + name: "protocolShare"; + docs: [ "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" + ]; + type: "u16"; }, { - "name": "index", - "docs": [ - "index" - ], - "type": "u16" + name: "index"; + docs: ["index"]; + type: "u16"; }, { - "name": "baseFeePowerFactor", - "docs": [ - "Base fee power factor" - ], - "type": "u8" + name: "baseFeePowerFactor"; + docs: ["Base fee power factor"]; + type: "u8"; }, { - "name": "padding0", - "docs": [ - "Padding 0 for future use" - ], - "type": "u8" + name: "padding0"; + docs: ["Padding 0 for future use"]; + type: "u8"; }, { - "name": "padding1", - "docs": [ - "Padding 1 for future use" - ], - "type": { - "array": [ - "u64", - 20 - ] - } + name: "padding1"; + docs: ["Padding 1 for future use"]; + type: { + array: ["u64", 20]; + }; } - ] - } + ]; + }; }, { - "name": "presetParameter", - "type": { - "kind": "struct", - "fields": [ + name: "protocolFee"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ { - "name": "binStep", - "docs": [ - "Bin step. Represent the price increment / decrement." - ], - "type": "u16" + name: "amountX"; + type: "u64"; }, { - "name": "baseFactor", - "docs": [ - "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" - ], - "type": "u16" + name: "amountY"; + type: "u64"; + } + ]; + }; + }, + { + name: "rebalanceLiquidityParams"; + type: { + kind: "struct"; + fields: [ + { + name: "activeId"; + docs: ["active id"]; + type: "i32"; }, { - "name": "filterPeriod", - "docs": [ - "Filter period determine high frequency trading time window." - ], - "type": "u16" + name: "maxActiveBinSlippage"; + docs: ["max active bin slippage allowed"]; + type: "u16"; }, { - "name": "decayPeriod", - "docs": [ - "Decay period determine when the volatile fee start decay / decrease." - ], - "type": "u16" + name: "shouldClaimFee"; + docs: ["a flag to indicate that whether fee should be harvested"]; + type: "bool"; }, { - "name": "reductionFactor", - "docs": [ - "Reduction factor controls the volatile fee rate decrement rate." - ], - "type": "u16" + name: "shouldClaimReward"; + docs: [ + "a flag to indicate that whether rewards should be harvested" + ]; + type: "bool"; }, { - "name": "variableFeeControl", - "docs": [ - "Used to scale the variable fee component depending on the dynamic of the market" - ], - "type": "u32" + name: "minWithdrawXAmount"; + docs: ["threshold for withdraw token x"]; + type: "u64"; }, { - "name": "maxVolatilityAccumulator", - "docs": [ - "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." - ], - "type": "u32" + name: "maxDepositXAmount"; + docs: ["threshold for deposit token x"]; + type: "u64"; }, { - "name": "minBinId", - "docs": [ - "Min bin id supported by the pool based on the configured bin step." - ], - "type": "i32" + name: "minWithdrawYAmount"; + docs: ["threshold for withdraw token y"]; + type: "u64"; }, { - "name": "maxBinId", - "docs": [ - "Max bin id supported by the pool based on the configured bin step." - ], - "type": "i32" + name: "maxDepositYAmount"; + docs: ["threshold for deposit token y"]; + type: "u64"; }, { - "name": "protocolShare", - "docs": [ - "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" - ], - "type": "u16" - } - ] - } - }, - { - "name": "tokenBadge", - "docs": [ - "Parameter that set by the protocol" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "tokenMint", - "docs": [ - "token mint" - ], - "type": "pubkey" - }, - { - "name": "padding", - "docs": [ - "Reserve" - ], - "type": { - "array": [ - "u8", - 128 - ] - } + name: "shrinkMode"; + docs: ["shrink mode"]; + type: "u8"; + }, + { + name: "padding"; + docs: ["padding 32 bytes for future usage"]; + type: { + array: ["u8", 31]; + }; + }, + { + name: "removes"; + docs: ["removes"]; + type: { + vec: { + defined: { + name: "removeLiquidityParams"; + }; + }; + }; + }, + { + name: "adds"; + docs: ["adds"]; + type: { + vec: { + defined: { + name: "addLiquidityParams"; + }; + }; + }; } - ] - } + ]; + }; }, { - "name": "compositionFee", - "type": { - "kind": "struct", - "fields": [ + name: "rebalancing"; + type: { + kind: "struct"; + fields: [ { - "name": "from", - "type": "pubkey" + name: "lbPair"; + type: "pubkey"; }, { - "name": "binId", - "type": "i16" + name: "position"; + type: "pubkey"; }, { - "name": "tokenXFeeAmount", - "type": "u64" + name: "owner"; + type: "pubkey"; }, { - "name": "tokenYFeeAmount", - "type": "u64" + name: "activeBinId"; + type: "i32"; }, { - "name": "protocolTokenXFeeAmount", - "type": "u64" + name: "xWithdrawnAmount"; + type: "u64"; }, { - "name": "protocolTokenYFeeAmount", - "type": "u64" - } - ] - } - }, - { - "name": "addLiquidity", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lbPair", - "type": "pubkey" + name: "xAddedAmount"; + type: "u64"; }, { - "name": "from", - "type": "pubkey" + name: "yWithdrawnAmount"; + type: "u64"; }, { - "name": "position", - "type": "pubkey" + name: "yAddedAmount"; + type: "u64"; }, { - "name": "amounts", - "type": { - "array": [ - "u64", - 2 - ] - } + name: "xFeeAmount"; + type: "u64"; }, { - "name": "activeBinId", - "type": "i32" - } - ] - } - }, - { - "name": "removeLiquidity", - "type": { - "kind": "struct", - "fields": [ + name: "yFeeAmount"; + type: "u64"; + }, { - "name": "lbPair", - "type": "pubkey" + name: "oldMinId"; + type: "i32"; }, { - "name": "from", - "type": "pubkey" + name: "oldMaxId"; + type: "i32"; }, { - "name": "position", - "type": "pubkey" + name: "newMinId"; + type: "i32"; }, { - "name": "amounts", - "type": { - "array": [ - "u64", - 2 - ] - } + name: "newMaxId"; + type: "i32"; }, { - "name": "activeBinId", - "type": "i32" + name: "rewards"; + type: { + array: ["u64", 2]; + }; } - ] - } + ]; + }; + }, + { + name: "remainingAccountsInfo"; + type: { + kind: "struct"; + fields: [ + { + name: "slices"; + type: { + vec: { + defined: { + name: "remainingAccountsSlice"; + }; + }; + }; + } + ]; + }; }, { - "name": "swap", - "type": { - "kind": "struct", - "fields": [ + name: "remainingAccountsSlice"; + type: { + kind: "struct"; + fields: [ { - "name": "lbPair", - "type": "pubkey" + name: "accountsType"; + type: { + defined: { + name: "accountsType"; + }; + }; }, { - "name": "from", - "type": "pubkey" - }, + name: "length"; + type: "u8"; + } + ]; + }; + }, + { + name: "removeLiquidity"; + type: { + kind: "struct"; + fields: [ { - "name": "startBinId", - "type": "i32" + name: "lbPair"; + type: "pubkey"; }, { - "name": "endBinId", - "type": "i32" + name: "from"; + type: "pubkey"; }, { - "name": "amountIn", - "type": "u64" + name: "position"; + type: "pubkey"; }, { - "name": "amountOut", - "type": "u64" + name: "amounts"; + type: { + array: ["u64", 2]; + }; }, { - "name": "swapForY", - "type": "bool" - }, + name: "activeBinId"; + type: "i32"; + } + ]; + }; + }, + { + name: "removeLiquidityParams"; + type: { + kind: "struct"; + fields: [ { - "name": "fee", - "type": "u64" + name: "minBinId"; + type: { + option: "i32"; + }; }, { - "name": "protocolFee", - "type": "u64" + name: "maxBinId"; + type: { + option: "i32"; + }; }, { - "name": "feeBps", - "type": "u128" + name: "bps"; + type: "u16"; }, { - "name": "hostFee", - "type": "u64" + name: "padding"; + type: { + array: ["u8", 16]; + }; } - ] - } + ]; + }; }, { - "name": "claimReward", - "type": { - "kind": "struct", - "fields": [ + name: "resizeSide"; + docs: ["Side of resize, 0 for lower and 1 for upper"]; + repr: { + kind: "rust"; + }; + type: { + kind: "enum"; + variants: [ { - "name": "lbPair", - "type": "pubkey" + name: "lower"; }, { - "name": "position", - "type": "pubkey" + name: "upper"; + } + ]; + }; + }, + { + name: "rewardInfo"; + docs: ["Stores the state relevant for tracking liquidity mining rewards"]; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "mint"; + docs: ["Reward token mint."]; + type: "pubkey"; }, { - "name": "owner", - "type": "pubkey" + name: "vault"; + docs: ["Reward vault token account."]; + type: "pubkey"; }, { - "name": "rewardIndex", - "type": "u64" + name: "funder"; + docs: ["Authority account that allows to fund rewards"]; + type: "pubkey"; }, { - "name": "totalReward", - "type": "u64" - } - ] - } - }, - { - "name": "fundReward", - "type": { - "kind": "struct", - "fields": [ + name: "rewardDuration"; + docs: ["LM reward duration in seconds."]; + type: "u64"; + }, { - "name": "lbPair", - "type": "pubkey" + name: "rewardDurationEnd"; + docs: ["LM reward duration end time."]; + type: "u64"; }, { - "name": "funder", - "type": "pubkey" + name: "rewardRate"; + docs: ["LM reward rate"]; + type: "u128"; }, { - "name": "rewardIndex", - "type": "u64" + name: "lastUpdateTime"; + docs: ["The last time reward states were updated."]; + type: "u64"; }, { - "name": "amount", - "type": "u64" + name: "cumulativeSecondsWithEmptyLiquidityReward"; + docs: [ + "Accumulated seconds where when farm distribute rewards, but the bin is empty. The reward will be accumulated for next reward time window." + ]; + type: "u64"; } - ] - } + ]; + }; }, { - "name": "initializeReward", - "type": { - "kind": "struct", - "fields": [ + name: "rounding"; + type: { + kind: "enum"; + variants: [ { - "name": "lbPair", - "type": "pubkey" + name: "up"; }, { - "name": "rewardMint", - "type": "pubkey" + name: "down"; + } + ]; + }; + }, + { + name: "staticParameters"; + docs: ["Parameter that set by the protocol"]; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "baseFactor"; + docs: [ + "Used for base fee calculation. base_fee_rate = base_factor * bin_step * 10 * 10^base_fee_power_factor" + ]; + type: "u16"; }, { - "name": "funder", - "type": "pubkey" + name: "filterPeriod"; + docs: [ + "Filter period determine high frequency trading time window." + ]; + type: "u16"; }, { - "name": "rewardIndex", - "type": "u64" + name: "decayPeriod"; + docs: [ + "Decay period determine when the volatile fee start decay / decrease." + ]; + type: "u16"; }, { - "name": "rewardDuration", - "type": "u64" - } - ] - } - }, - { - "name": "updateRewardDuration", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lbPair", - "type": "pubkey" + name: "reductionFactor"; + docs: [ + "Reduction factor controls the volatile fee rate decrement rate." + ]; + type: "u16"; }, { - "name": "rewardIndex", - "type": "u64" + name: "variableFeeControl"; + docs: [ + "Used to scale the variable fee component depending on the dynamic of the market" + ]; + type: "u32"; }, { - "name": "oldRewardDuration", - "type": "u64" + name: "maxVolatilityAccumulator"; + docs: [ + "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate." + ]; + type: "u32"; }, { - "name": "newRewardDuration", - "type": "u64" - } - ] - } - }, - { - "name": "updateRewardFunder", - "type": { - "kind": "struct", - "fields": [ + name: "minBinId"; + docs: [ + "Min bin id supported by the pool based on the configured bin step." + ]; + type: "i32"; + }, { - "name": "lbPair", - "type": "pubkey" + name: "maxBinId"; + docs: [ + "Max bin id supported by the pool based on the configured bin step." + ]; + type: "i32"; }, { - "name": "rewardIndex", - "type": "u64" + name: "protocolShare"; + docs: [ + "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee" + ]; + type: "u16"; }, { - "name": "oldFunder", - "type": "pubkey" + name: "baseFeePowerFactor"; + docs: ["Base fee power factor"]; + type: "u8"; }, { - "name": "newFunder", - "type": "pubkey" + name: "padding"; + docs: ["Padding for bytemuck safe alignment"]; + type: { + array: ["u8", 5]; + }; } - ] - } + ]; + }; }, { - "name": "positionClose", - "type": { - "kind": "struct", - "fields": [ + name: "strategyParameters"; + type: { + kind: "struct"; + fields: [ + { + name: "minBinId"; + docs: ["min bin id"]; + type: "i32"; + }, { - "name": "position", - "type": "pubkey" + name: "maxBinId"; + docs: ["max bin id"]; + type: "i32"; }, { - "name": "owner", - "type": "pubkey" + name: "strategyType"; + docs: ["strategy type"]; + type: { + defined: { + name: "strategyType"; + }; + }; + }, + { + name: "parameteres"; + docs: ["parameters"]; + type: { + array: ["u8", 64]; + }; } - ] - } + ]; + }; }, { - "name": "claimFee", - "type": { - "kind": "struct", - "fields": [ + name: "strategyType"; + type: { + kind: "enum"; + variants: [ { - "name": "lbPair", - "type": "pubkey" + name: "spotOneSide"; }, { - "name": "position", - "type": "pubkey" + name: "curveOneSide"; }, { - "name": "owner", - "type": "pubkey" + name: "bidAskOneSide"; }, { - "name": "feeX", - "type": "u64" + name: "spotBalanced"; }, { - "name": "feeY", - "type": "u64" - } - ] - } - }, - { - "name": "lbPairCreate", - "type": { - "kind": "struct", - "fields": [ + name: "curveBalanced"; + }, { - "name": "lbPair", - "type": "pubkey" + name: "bidAskBalanced"; }, { - "name": "binStep", - "type": "u16" + name: "spotImBalanced"; }, { - "name": "tokenX", - "type": "pubkey" + name: "curveImBalanced"; }, { - "name": "tokenY", - "type": "pubkey" + name: "bidAskImBalanced"; } - ] - } + ]; + }; }, { - "name": "positionCreate", - "type": { - "kind": "struct", - "fields": [ + name: "swap"; + type: { + kind: "struct"; + fields: [ { - "name": "lbPair", - "type": "pubkey" + name: "lbPair"; + type: "pubkey"; }, { - "name": "position", - "type": "pubkey" + name: "from"; + type: "pubkey"; }, { - "name": "owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "increasePositionLength", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lbPair", - "type": "pubkey" + name: "startBinId"; + type: "i32"; }, { - "name": "position", - "type": "pubkey" + name: "endBinId"; + type: "i32"; }, { - "name": "owner", - "type": "pubkey" + name: "amountIn"; + type: "u64"; }, { - "name": "lengthToAdd", - "type": "u16" + name: "amountOut"; + type: "u64"; }, { - "name": "side", - "type": "u8" - } - ] - } - }, - { - "name": "decreasePositionLength", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lbPair", - "type": "pubkey" + name: "swapForY"; + type: "bool"; }, { - "name": "position", - "type": "pubkey" + name: "fee"; + type: "u64"; }, { - "name": "owner", - "type": "pubkey" + name: "protocolFee"; + type: "u64"; }, { - "name": "lengthToRemove", - "type": "u16" + name: "feeBps"; + type: "u128"; }, { - "name": "side", - "type": "u8" + name: "hostFee"; + 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": "feeParameterUpdate", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lbPair", - "type": "pubkey" - }, + name: "tokenProgramFlags"; + repr: { + kind: "rust"; + }; + type: { + kind: "enum"; + variants: [ { - "name": "protocolShare", - "type": "u16" + name: "tokenProgram"; }, { - "name": "baseFactor", - "type": "u16" + name: "tokenProgram2022"; } - ] - } + ]; + }; }, { - "name": "dynamicFeeParameterUpdate", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lbPair", - "type": "pubkey" - }, + name: "updatePositionLockReleasePoint"; + type: { + kind: "struct"; + fields: [ { - "name": "filterPeriod", - "type": "u16" + name: "position"; + type: "pubkey"; }, { - "name": "decayPeriod", - "type": "u16" + name: "currentPoint"; + type: "u64"; }, { - "name": "reductionFactor", - "type": "u16" + name: "newLockReleasePoint"; + type: "u64"; }, { - "name": "variableFeeControl", - "type": "u32" + name: "oldLockReleasePoint"; + type: "u64"; }, { - "name": "maxVolatilityAccumulator", - "type": "u32" + name: "sender"; + type: "pubkey"; } - ] - } + ]; + }; }, { - "name": "increaseObservation", - "type": { - "kind": "struct", - "fields": [ + name: "updatePositionOperator"; + type: { + kind: "struct"; + fields: [ + { + name: "position"; + type: "pubkey"; + }, { - "name": "oracle", - "type": "pubkey" + name: "oldOperator"; + type: "pubkey"; }, { - "name": "newObservationLength", - "type": "u64" + name: "newOperator"; + type: "pubkey"; } - ] - } + ]; + }; }, { - "name": "withdrawIneligibleReward", - "type": { - "kind": "struct", - "fields": [ + name: "updateRewardDuration"; + type: { + kind: "struct"; + fields: [ + { + name: "lbPair"; + type: "pubkey"; + }, { - "name": "lbPair", - "type": "pubkey" + name: "rewardIndex"; + type: "u64"; }, { - "name": "rewardMint", - "type": "pubkey" + name: "oldRewardDuration"; + type: "u64"; }, { - "name": "amount", - "type": "u64" + name: "newRewardDuration"; + type: "u64"; } - ] - } + ]; + }; }, { - "name": "updatePositionOperator", - "type": { - "kind": "struct", - "fields": [ + name: "updateRewardFunder"; + type: { + kind: "struct"; + fields: [ + { + name: "lbPair"; + type: "pubkey"; + }, { - "name": "position", - "type": "pubkey" + name: "rewardIndex"; + type: "u64"; }, { - "name": "oldOperator", - "type": "pubkey" + name: "oldFunder"; + type: "pubkey"; }, { - "name": "newOperator", - "type": "pubkey" + name: "newFunder"; + type: "pubkey"; } - ] - } + ]; + }; }, { - "name": "updatePositionLockReleasePoint", - "type": { - "kind": "struct", - "fields": [ + name: "userRewardInfo"; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "rewardPerTokenCompletes"; + type: { + array: ["u128", 2]; + }; + }, + { + name: "rewardPendings"; + type: { + array: ["u64", 2]; + }; + } + ]; + }; + }, + { + name: "variableParameters"; + docs: ["Parameters that changes based on dynamic of the market"]; + serialization: "bytemuck"; + repr: { + kind: "c"; + }; + type: { + kind: "struct"; + fields: [ + { + name: "volatilityAccumulator"; + docs: [ + "Volatility accumulator measure the number of bin crossed since reference bin ID. Normally (without filter period taken into consideration), reference bin ID is the active bin of last swap.", + "It affects the variable fee rate" + ]; + type: "u32"; + }, { - "name": "position", - "type": "pubkey" + name: "volatilityReference"; + docs: [ + "Volatility reference is decayed volatility accumulator. It is always <= volatility_accumulator" + ]; + type: "u32"; }, { - "name": "currentPoint", - "type": "u64" + name: "indexReference"; + docs: ["Active bin id of last swap."]; + type: "i32"; }, { - "name": "newLockReleasePoint", - "type": "u64" + name: "padding"; + docs: ["Padding for bytemuck safe alignment"]; + type: { + array: ["u8", 4]; + }; }, { - "name": "oldLockReleasePoint", - "type": "u64" + name: "lastUpdateTimestamp"; + docs: ["Last timestamp the variable parameters was updated"]; + type: "i64"; }, { - "name": "sender", - "type": "pubkey" + name: "padding1"; + docs: ["Padding for bytemuck safe alignment"]; + type: { + array: ["u8", 8]; + }; } - ] - } + ]; + }; }, { - "name": "goToABin", - "type": { - "kind": "struct", - "fields": [ + name: "withdrawIneligibleReward"; + type: { + kind: "struct"; + fields: [ { - "name": "lbPair", - "type": "pubkey" + name: "lbPair"; + type: "pubkey"; }, { - "name": "fromBinId", - "type": "i32" + name: "rewardMint"; + type: "pubkey"; }, { - "name": "toBinId", - "type": "i32" + name: "amount"; + type: "u64"; } - ] - } + ]; + }; } - ], - "constants": [ + ]; + constants: [ { - "name": "basisPointMax", - "type": "i32", - "value": "10000" + name: "basisPointMax"; + type: "i32"; + value: "10000"; }, { - "name": "maxBinPerArray", - "type": { - "defined": { - "name": "usize" - } - }, - "value": "70" + name: "binArray"; + type: "bytes"; + value: "[98, 105, 110, 95, 97, 114, 114, 97, 121]"; }, { - "name": "maxBinPerPosition", - "type": { - "defined": { - "name": "usize" - } - }, - "value": "70" + name: "binArrayBitmapSeed"; + type: "bytes"; + value: "[98, 105, 116, 109, 97, 112]"; }, { - "name": "maxResizeLength", - "type": { - "defined": { - "name": "usize" - } - }, - "value": "70" + name: "binArrayBitmapSize"; + type: "i32"; + value: "512"; }, { - "name": "positionMaxLength", - "type": { - "defined": { - "name": "usize" - } - }, - "value": "1400" + name: "claimProtocolFeeOperator"; + type: "bytes"; + value: "[99, 102, 95, 111, 112, 101, 114, 97, 116, 111, 114]"; }, { - "name": "minBinId", - "type": "i32", - "value": "- 443636" + name: "defaultBinPerPosition"; + type: "u64"; + value: "70"; }, { - "name": "maxBinId", - "type": "i32", - "value": "443636" + name: "extensionBinarrayBitmapSize"; + type: "u64"; + value: "12"; }, { - "name": "maxFeeRate", - "type": "u64", - "value": "100000000" + name: "feePrecision"; + type: "u64"; + value: "1000000000"; }, { - "name": "feePrecision", - "type": "u64", - "value": "1000000000" + name: "hostFeeBps"; + docs: ["Host fee. 20%"]; + type: "u16"; + value: "2000"; }, { - "name": "maxProtocolShare", - "type": "u16", - "value": "2500" + name: "ilmProtocolShare"; + type: "u16"; + value: "2000"; }, { - "name": "hostFeeBps", - "type": "u16", - "value": "2000" + name: "maxBaseFee"; + docs: ["Maximum base fee, base_fee / 10^9 = fee_in_percentage"]; + type: "u128"; + value: "100000000"; }, { - "name": "numRewards", - "type": { - "defined": { - "name": "usize" - } - }, - "value": "2" + name: "maxBinId"; + docs: ["Maximum bin ID supported. Computed based on 1 bps."]; + type: "i32"; + value: "443636"; }, { - "name": "minRewardDuration", - "type": "u64", - "value": "1" + name: "maxBinPerArray"; + type: "u64"; + value: "70"; }, { - "name": "maxRewardDuration", - "type": "u64", - "value": "31536000" + name: "maxBinStep"; + docs: ["Maximum bin step"]; + type: "u16"; + value: "400"; }, { - "name": "extensionBinarrayBitmapSize", - "type": { - "defined": { - "name": "usize" - } - }, - "value": "12" + name: "maxFeeRate"; + docs: ["Maximum fee rate. 10%"]; + type: "u64"; + value: "100000000"; }, { - "name": "binArrayBitmapSize", - "type": "i32", - "value": "512" + name: "maxProtocolShare"; + docs: ["Maximum protocol share of the fee. 25%"]; + type: "u16"; + value: "2500"; }, { - "name": "maxRewardBinSplit", - "type": { - "defined": { - "name": "usize" - } - }, - "value": "15" + name: "maxResizeLength"; + type: "u64"; + value: "91"; }, { - "name": "ilmProtocolShare", - "type": "u16", - "value": "2000" + name: "maxRewardBinSplit"; + type: "u64"; + value: "15"; }, { - "name": "protocolShare", - "type": "u16", - "value": "500" + name: "maxRewardDuration"; + type: "u64"; + value: "31536000"; }, { - "name": "maxBinStep", - "type": "u16", - "value": "400" + name: "minimumLiquidity"; + type: "u128"; + value: "1000000"; }, { - "name": "maxBaseFee", - "type": "u128", - "value": "100000000" + name: "minBaseFee"; + docs: ["Minimum base fee"]; + type: "u128"; + value: "100000"; }, { - "name": "minBaseFee", - "type": "u128", - "value": "100000" + name: "minBinId"; + docs: ["Minimum bin ID supported. Computed based on 1 bps."]; + type: "i32"; + value: "-443636"; }, { - "name": "minimumLiquidity", - "type": "u128", - "value": "1000000" + name: "minRewardDuration"; + type: "u64"; + value: "1"; }, { - "name": "binArray", - "type": "bytes", - "value": "[98, 105, 110, 95, 97, 114, 114, 97, 121]" + name: "numRewards"; + type: "u64"; + value: "2"; }, { - "name": "oracle", - "type": "bytes", - "value": "[111, 114, 97, 99, 108, 101]" + name: "oracle"; + type: "bytes"; + value: "[111, 114, 97, 99, 108, 101]"; }, { - "name": "binArrayBitmapSeed", - "type": "bytes", - "value": "[98, 105, 116, 109, 97, 112]" + name: "position"; + type: "bytes"; + value: "[112, 111, 115, 105, 116, 105, 111, 110]"; }, { - "name": "presetParameter", - "type": "bytes", - "value": "[112, 114, 101, 115, 101, 116, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114]" + name: "positionMaxLength"; + type: "u64"; + value: "1400"; }, { - "name": "presetParameter2", - "type": "bytes", - "value": "[112, 114, 101, 115, 101, 116, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114, 50]" + name: "presetParameter"; + type: "bytes"; + value: "[112, 114, 101, 115, 101, 116, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114]"; }, { - "name": "position", - "type": "bytes", - "value": "[112, 111, 115, 105, 116, 105, 111, 110]" + name: "presetParameter2"; + type: "bytes"; + value: "[112, 114, 101, 115, 101, 116, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114, 50]"; }, { - "name": "claimProtocolFeeOperator", - "type": "bytes", - "value": "[99, 102, 95, 111, 112, 101, 114, 97, 116, 111, 114]" + name: "protocolShare"; + type: "u16"; + value: "500"; } - ] + ]; }; diff --git a/tests/common/index.ts b/tests/common/index.ts index 92abf28..a8efab4 100644 --- a/tests/common/index.ts +++ b/tests/common/index.ts @@ -1,3 +1,3 @@ export * from "./damm_v2"; export * from "./utils"; -export * from "./zap"; +export * from "./endpoints"; diff --git a/tests/common/math.ts b/tests/common/math.ts new file mode 100644 index 0000000..1996cd0 --- /dev/null +++ b/tests/common/math.ts @@ -0,0 +1,151 @@ +import BN from "bn.js"; + +const MAX_EXPONENTIAL = new BN(0x80000); +const SCALE_OFFSET = 64; + +const ONE = new BN(1).shln(SCALE_OFFSET); +const MAX = new BN(2).pow(new BN(128)).sub(new BN(1)); + +export function pow(base: BN, exp: BN): BN { + let invert = exp.isNeg(); + + if (exp.isZero()) { + return ONE; + } + + exp = invert ? exp.abs() : exp; + + if (exp.gt(MAX_EXPONENTIAL)) { + return new BN(0); + } + + let squaredBase = base; + let result = ONE; + + if (squaredBase.gte(result)) { + squaredBase = MAX.div(squaredBase); + invert = !invert; + } + + if (!exp.and(new BN(0x1)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x2)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x4)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x8)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x10)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x20)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x40)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x80)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x100)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x200)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x400)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x800)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x1000)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x2000)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x4000)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x8000)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x10000)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x20000)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + squaredBase = squaredBase.mul(squaredBase).shrn(SCALE_OFFSET); + + if (!exp.and(new BN(0x40000)).isZero()) { + result = result.mul(squaredBase).shrn(SCALE_OFFSET); + } + + if (result.isZero()) { + return new BN(0); + } + + if (invert) { + result = MAX.div(result); + } + + return result; +} diff --git a/tests/common/pda.ts b/tests/common/pda.ts index 79d233e..f19a27f 100644 --- a/tests/common/pda.ts +++ b/tests/common/pda.ts @@ -8,6 +8,16 @@ import { Position, } from "./damm_v2"; import { LiteSVM } from "litesvm"; +import { ZAP_PROGRAM_ID } from "./endpoints"; + +////// ZAP PDA ///// + +export function deriveLedgerAccount(owner: PublicKey): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("user_ledger"), owner.toBuffer()], + ZAP_PROGRAM_ID + )[0]; +} ///////// DAMM V2 //////////// @@ -125,6 +135,18 @@ export function deriveLbPermissionless2( ); } +export function deriveLbCustomizablePermissionless2( + tokenX: PublicKey, + tokenY: PublicKey +): PublicKey { + const baseKey = new PublicKey("MFGQxwAmB91SwuYX36okv2Qmdc9aMuHTwWGUrp4AtB1"); + const [minKey, maxKey] = sortTokenMints(tokenX, tokenY); + return PublicKey.findProgramAddressSync( + [baseKey.toBuffer(), minKey.toBuffer(), maxKey.toBuffer()], + DLMM_PROGRAM_ID_LOCAL + )[0]; +} + export function deriveReserve(token: PublicKey, lbPair: PublicKey) { return PublicKey.findProgramAddressSync( [lbPair.toBuffer(), token.toBuffer()], diff --git a/tests/common/transferHook/idl/transfer_hook.ts b/tests/common/transferHook/idl/transfer_hook.ts index 95bf073..f4d0137 100644 --- a/tests/common/transferHook/idl/transfer_hook.ts +++ b/tests/common/transferHook/idl/transfer_hook.ts @@ -5,132 +5,105 @@ * IDL can be found at `target/idl/transfer_hook_counter.json`. */ export type TransferHookCounter = { - "address": "EBZDYx7599krFc4m2govwBdZcicr4GgepqC78m71nsHS", - "metadata": { - "name": "transferHookCounter", - "version": "0.1.0", - "spec": "0.1.0" - }, - "instructions": [ + address: "EBZDYx7599krFc4m2govwBdZcicr4GgepqC78m71nsHS"; + metadata: { + name: "transferHookCounter"; + version: "0.1.0"; + spec: "0.1.0"; + }; + instructions: [ { - "name": "initializeExtraAccountMetaList", - "discriminator": [ - 92, - 197, - 174, - 197, - 41, - 124, - 19, - 3 - ], - "accounts": [ + name: "initializeExtraAccountMetaList"; + discriminator: [92, 197, 174, 197, 41, 124, 19, 3]; + accounts: [ { - "name": "payer", - "writable": true, - "signer": true + name: "payer"; + writable: true; + signer: true; }, { - "name": "extraAccountMetaList", - "writable": true + name: "extraAccountMetaList"; + writable: true; }, { - "name": "mint" + name: "mint"; }, { - "name": "counterAccount", - "writable": true + name: "counterAccount"; + writable: true; }, { - "name": "tokenProgram" + name: "tokenProgram"; }, { - "name": "associatedTokenProgram" + name: "associatedTokenProgram"; }, { - "name": "systemProgram" + name: "systemProgram"; } - ], - "args": [] + ]; + args: []; }, { - "name": "transferHook", - "discriminator": [ - 220, - 57, - 220, - 152, - 126, - 125, - 97, - 168 - ], - "accounts": [ + name: "transferHook"; + discriminator: [220, 57, 220, 152, 126, 125, 97, 168]; + accounts: [ { - "name": "sourceToken" + name: "sourceToken"; }, { - "name": "mint" + name: "mint"; }, { - "name": "destinationToken" + name: "destinationToken"; }, { - "name": "owner" + name: "owner"; }, { - "name": "extraAccountMetaList" + name: "extraAccountMetaList"; }, { - "name": "counterAccount", - "writable": true + name: "counterAccount"; + writable: true; }, { - "name": "accountOrderVerifier" + name: "accountOrderVerifier"; } - ], - "args": [ + ]; + args: [ { - "name": "amount", - "type": "u64" + name: "amount"; + type: "u64"; } - ] + ]; } - ], - "accounts": [ + ]; + accounts: [ { - "name": "counterAccount", - "discriminator": [ - 164, - 8, - 153, - 71, - 8, - 44, - 93, - 22 - ] + name: "counterAccount"; + discriminator: [164, 8, 153, 71, 8, 44, 93, 22]; } - ], - "errors": [ + ]; + errors: [ { - "code": 6000, - "name": "amountTooBig", - "msg": "The amount is too big" + code: 6000; + name: "amountTooBig"; + msg: "The amount is too big"; } - ], - "types": [ + ]; + types: [ { - "name": "counterAccount", - "type": { - "kind": "struct", - "fields": [ + name: "counterAccount"; + type: { + kind: "struct"; + fields: [ { - "name": "counter", - "type": "u32" + name: "counter"; + type: "u32"; } - ] - } + ]; + }; } - ] + ]; }; diff --git a/tests/common/utils.ts b/tests/common/utils.ts index 48c0ee0..8cdc070 100644 --- a/tests/common/utils.ts +++ b/tests/common/utils.ts @@ -228,8 +228,28 @@ export function getTokenProgram(svm: LiteSVM, tokenMint: PublicKey): PublicKey { export function getTokenBalance(svm: LiteSVM, tokenAccount: PublicKey): BN { const account = svm.getAccount(tokenAccount); - if(!account.data) { - return new BN(0) + if (!account.data) { + return new BN(0); } return new BN(AccountLayout.decode(account.data).amount.toString()); } + +export function convertAccountTypeToNumber(accountType: object): number { + if (JSON.stringify(accountType) === JSON.stringify({ transferHookX: {} })) { + return 0; + } + + if (JSON.stringify(accountType) === JSON.stringify({ transferHookY: {} })) { + return 1; + } + if ( + JSON.stringify(accountType) === JSON.stringify({ transferHookReward: {} }) + ) { + return 2; + } +} + +export function warpSlotBy(svm: LiteSVM, slots: BN) { + const clock = svm.getClock(); + svm.warpToSlot(clock.slot + BigInt(slots.toString())); +} diff --git a/tests/fixtures/damm_v2.so b/tests/fixtures/damm_v2.so index 9219a14..abd3200 100755 Binary files a/tests/fixtures/damm_v2.so and b/tests/fixtures/damm_v2.so differ diff --git a/tests/fixtures/dlmm.so b/tests/fixtures/dlmm.so index 12c4cf7..ce3840e 100755 Binary files a/tests/fixtures/dlmm.so and b/tests/fixtures/dlmm.so differ diff --git a/tests/test_zapin/zapin_dammv2.test.ts b/tests/test_zapin/zapin_dammv2.test.ts new file mode 100644 index 0000000..7416629 --- /dev/null +++ b/tests/test_zapin/zapin_dammv2.test.ts @@ -0,0 +1,407 @@ +import { + FailedTransactionMetadata, + LiteSVM, + TransactionMetadata, +} from "litesvm"; +import { + PublicKey, + Keypair, + LAMPORTS_PER_SOL, + Transaction, +} from "@solana/web3.js"; +import { + createZapProgram, + createToken, + mintToken, + ZapProgram, + initializeLedgerAccount, + setLedgerBalance, + updateLedgerBalanceAfterSwap, + getTokenBalance, + zapInDammv2, + closeLedgerAccount, + warpSlotBy, + TOKEN_DECIMALS, + U64_MAX, +} from "../common"; + +import ZapIDL from "../../target/idl/zap.json"; +import DAMMV2IDL from "../../idls/damm_v2.json"; +import { + convertToRateLimiterSecondFactor, + createDammV2Pool, + createDammV2Position, + swap, +} from "../common/damm_v2"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; +import { BN } from "@coral-xyz/anchor"; +import { getDammV2Pool, getDammV2Position } from "../common/pda"; +import { expect } from "chai"; +import fs from "fs"; + +describe("Zap In damm V2", () => { + let zapProgram: ZapProgram; + let svm: LiteSVM; + let tokenMint: PublicKey; + let user: Keypair; + let admin: Keypair; + let tokenAMint: PublicKey; + let tokenBMint: PublicKey; + beforeEach(async () => { + zapProgram = createZapProgram(); + svm = new LiteSVM(); + svm.addProgramFromFile( + new PublicKey(ZapIDL.address), + "./target/deploy/zap.so" + ); + svm.addProgramFromFile( + new PublicKey(DAMMV2IDL.address), + "./tests/fixtures/damm_v2.so" + ); + + user = Keypair.generate(); + admin = Keypair.generate(); + svm.airdrop(user.publicKey, BigInt(LAMPORTS_PER_SOL)); + svm.airdrop(admin.publicKey, BigInt(LAMPORTS_PER_SOL)); + + tokenAMint = createToken(svm, admin, admin.publicKey, null); + tokenBMint = createToken(svm, admin, admin.publicKey, null); + mintToken(svm, admin, tokenAMint, admin, admin.publicKey); + mintToken(svm, admin, tokenBMint, admin, admin.publicKey); + + mintToken(svm, admin, tokenAMint, admin, user.publicKey); + mintToken(svm, admin, tokenBMint, admin, user.publicKey); + }); + + it("happy path zap in", async () => { + const pool = await createDammV2Pool(svm, admin, tokenAMint, tokenBMint); + + const { position, positionNftAccount } = await createDammV2Position( + svm, + user, + pool + ); + + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + await zapInFullFlow({ + svm, + user, + pool, + position, + positionNftAccount, + inputTokenMint: tokenAMint, + outputTokenMint: tokenBMint, + totalAmount: amountTokenA, + amountSwap, + }); + }); + + it("zap in with pool has fee scheduler", async () => { + const baseFee = { + cliffFeeNumerator: new BN(500_000_000), // 50 % + firstFactor: 100, // 100 periods + secondFactor: Array.from(new BN(1).toArrayLike(Buffer, "le", 8)), + thirdFactor: new BN(4875000), + baseFeeMode: 0, // fee scheduler Linear mode + }; + + warpSlotBy(svm, new BN(10)); + + const pool = await createDammV2Pool( + svm, + admin, + tokenAMint, + tokenBMint, + undefined, + undefined, + baseFee + ); + + const { position, positionNftAccount } = await createDammV2Position( + svm, + user, + pool + ); + + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + await zapInFullFlow({ + svm, + user, + pool, + position, + positionNftAccount, + inputTokenMint: tokenAMint, + outputTokenMint: tokenBMint, + totalAmount: amountTokenA, + amountSwap, + }); + }); + + it("zap in with pool has rate limiter", async () => { + let maxRateLimiterDuration = new BN(10); + let maxFeeBps = new BN(5000); + const baseFee = { + cliffFeeNumerator: new BN(10_000_000), // 100bps + firstFactor: 10, // 10 bps + secondFactor: convertToRateLimiterSecondFactor( + maxRateLimiterDuration, + maxFeeBps + ), + thirdFactor: new BN(LAMPORTS_PER_SOL), // 1 SOL, + baseFeeMode: 2, // rate limiter mode + }; + + const pool = await createDammV2Pool( + svm, + admin, + tokenAMint, + tokenBMint, + undefined, + undefined, + baseFee + ); + + const { position, positionNftAccount } = await createDammV2Position( + svm, + user, + pool + ); + + const amountTokenA = new BN(5 * LAMPORTS_PER_SOL); // 5 SOL + const amountSwap = amountTokenA.divn(2); + await zapInFullFlow({ + svm, + user, + pool, + position, + positionNftAccount, + inputTokenMint: tokenAMint, + outputTokenMint: tokenBMint, + totalAmount: amountTokenA, + amountSwap, + }); + }); + + it("zap in with pool low liquidity", async () => { + const pool = await createDammV2Pool( + svm, + admin, + tokenAMint, + tokenBMint, + new BN(LAMPORTS_PER_SOL), + new BN(LAMPORTS_PER_SOL) + ); + + const { position, positionNftAccount } = await createDammV2Position( + svm, + user, + pool + ); + + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + await zapInFullFlow({ + svm, + user, + pool, + position, + positionNftAccount, + inputTokenMint: tokenAMint, + outputTokenMint: tokenBMint, + totalAmount: amountTokenA, + amountSwap, + }); + }); + + it("zap in without external swap", async () => { + const pool = await createDammV2Pool( + svm, + admin, + tokenAMint, + tokenBMint, + new BN(LAMPORTS_PER_SOL), + new BN(LAMPORTS_PER_SOL) + ); + + const { position, positionNftAccount } = await createDammV2Position( + svm, + user, + pool + ); + + let poolState = getDammV2Pool(svm, pool); + + const totalAmountA = new BN(LAMPORTS_PER_SOL / 2); // 0.5 SOL + const initializeLedgerTx = await initializeLedgerAccount(user.publicKey); + + const setLedgerBalanceTx = await setLedgerBalance( + user.publicKey, + totalAmountA, + true + ); + + const tokenBAccount = getAssociatedTokenAddressSync( + tokenBMint, + user.publicKey + ); + + const preTokenBBalance = getTokenBalance(svm, tokenBAccount); + + const updateLedgerBalanceAfterSwapTx = await updateLedgerBalanceAfterSwap( + user.publicKey, + tokenBAccount, + preTokenBBalance, + U64_MAX, + false + ); + + // zapin + + const zapInTx = await zapInDammv2({ + svm, + user: user.publicKey, + pool, + position, + positionNftAccount, + preSqrtPrice: poolState.sqrtPrice, + maxSqrtPriceChangeBps: 5000, + }); + + // close ledge + const closeLedgerTx = await closeLedgerAccount(user.publicKey); + + const finalTx = new Transaction() + .add(initializeLedgerTx) + .add(setLedgerBalanceTx) + .add(updateLedgerBalanceAfterSwapTx) + .add(zapInTx) + .add(closeLedgerTx); + + finalTx.recentBlockhash = svm.latestBlockhash(); + finalTx.sign(user); + + const result = svm.sendTransaction(finalTx); + if (result instanceof FailedTransactionMetadata) { + console.log(result.meta().logs()); + } + expect(result).instanceOf(TransactionMetadata); + }); +}); + +async function zapInFullFlow(params: { + svm: LiteSVM; + user: Keypair; + pool: PublicKey; + position: PublicKey; + positionNftAccount: PublicKey; + inputTokenMint: PublicKey; + outputTokenMint: PublicKey; + totalAmount: BN; + amountSwap: BN; +}) { + const { + svm, + user, + pool, + position, + positionNftAccount, + inputTokenMint, + outputTokenMint, + amountSwap, + totalAmount, + } = params; + + let poolState = getDammV2Pool(svm, pool); + const swapTx = await swap({ + svm, + user: user.publicKey, + pool, + amountIn: amountSwap, + inputTokenMint, + outputTokenMint, + }); + + const initializeLedgerTx = await initializeLedgerAccount(user.publicKey); + + const setLedgerBalanceTx = await setLedgerBalance( + user.publicKey, + totalAmount.sub(amountSwap), + inputTokenMint.equals(poolState.tokenAMint) + ); + + const tokenAAccount = getAssociatedTokenAddressSync( + inputTokenMint, + user.publicKey + ); + + const tokenBAccount = getAssociatedTokenAddressSync( + outputTokenMint, + user.publicKey + ); + + const preTokenABalance = getTokenBalance(svm, tokenAAccount); + const preTokenBBalance = getTokenBalance(svm, tokenBAccount); + + const updateLedgerBalanceAfterSwapTx = await updateLedgerBalanceAfterSwap( + user.publicKey, + tokenBAccount, + preTokenBBalance, + U64_MAX, + outputTokenMint.equals(poolState.tokenAMint) + ); + + // zapin + + const zapInTx = await zapInDammv2({ + svm, + user: user.publicKey, + pool, + position, + positionNftAccount, + preSqrtPrice: poolState.sqrtPrice, + maxSqrtPriceChangeBps: 5000, + }); + + // close ledge + const closeLedgerTx = await closeLedgerAccount(user.publicKey); + + const finalTx = new Transaction() + .add(swapTx) + .add(initializeLedgerTx) + .add(setLedgerBalanceTx) + .add(updateLedgerBalanceAfterSwapTx) + .add(zapInTx) + .add(closeLedgerTx); + + finalTx.recentBlockhash = svm.latestBlockhash(); + finalTx.sign(user); + + const result = svm.sendTransaction(finalTx); + // if (result instanceof TransactionMetadata) { + // console.log(result.logs()); + // } + expect(result).instanceOf(TransactionMetadata); + + // check position after add liquidity + const positionState = getDammV2Position(svm, position); + poolState = getDammV2Pool(svm, pool); + + expect(positionState.unlockedLiquidity.gt(new BN(0))).to.be.true; + + const postTokenABalance = getTokenBalance(svm, tokenAAccount); + const postTokenBBalance = getTokenBalance(svm, tokenBAccount); + + const remainingTokenA = totalAmount + .add(postTokenABalance) + .sub(preTokenABalance); + + const remainingTokenB = postTokenBBalance.sub(preTokenBBalance); + + const remainAmountAPercent = + remainingTokenA.toNumber() / totalAmount.toNumber(); + + expect(remainAmountAPercent < 0.001); // 0.1% + expect(remainingTokenB.toNumber() < 0.0001 * 10 ** TOKEN_DECIMALS); // 0.0001 token +} diff --git a/tests/test_zapin/zapin_dlmm_initialize_position.test.ts b/tests/test_zapin/zapin_dlmm_initialize_position.test.ts new file mode 100644 index 0000000..89b5f05 --- /dev/null +++ b/tests/test_zapin/zapin_dlmm_initialize_position.test.ts @@ -0,0 +1,441 @@ +import { + FailedTransactionMetadata, + LiteSVM, + TransactionMetadata, +} from "litesvm"; +import { + PublicKey, + Keypair, + LAMPORTS_PER_SOL, + Transaction, + AccountMeta, +} from "@solana/web3.js"; +import { + createToken, + mintToken, + TOKEN_DECIMALS, + initializeLedgerAccount, + setLedgerBalance, + getTokenBalance, + updateLedgerBalanceAfterSwap, + zapInDlmmforInitializedPosition, + closeLedgerAccount, + U64_MAX, +} from "../common"; +import babar from "babar"; +import { expect } from "chai"; + +import ZapIDL from "../../target/idl/zap.json"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; +import { + binIdToBinArrayIndex, + createBinArrays, + createDlmmPosition, + DLMM_PROGRAM_ID_LOCAL, + dlmmCreatePositionAndAddLiquidityRadius, + dlmmSwap, + getLbPairState, + getPositionTotalLiquidityAllBin, + DEFAULT_BIN_PER_POSITION, + RemainingAccountsInfo, + StrategyType, + createDlmmPermissionlessPool, + SET_COMPUTE_UNIT_LIMIT_IX, + initializeBinArrayBitmapExtension, + getBinArrayAccountMetaByBinRange, +} from "../common/dlmm"; +import { BN } from "@coral-xyz/anchor"; +import { deriveBinArrayBitmapExtension } from "../common/pda"; + +describe("Zapin DLMM with initialize position", () => { + let svm: LiteSVM; + let user: Keypair; + let tokenXMint: PublicKey; + let tokenYMint: PublicKey; + let lbPair: PublicKey; + + const binStep = new BN(10); + const activeId = new BN(5660); + const lowerBinId = + activeId.toNumber() - DEFAULT_BIN_PER_POSITION.toNumber() / 2; + // 5 = Create 5 lower bin arrays, and 5 upper bin arrays surrounding the active bin arrays. Total bins = 600 * 11 + const binArrayDelta = 5; + const upperBinId = DEFAULT_BIN_PER_POSITION.toNumber() + lowerBinId - 1; + + const minDeltaId = -DEFAULT_BIN_PER_POSITION.toNumber() / 2; + const maxDeltaId = DEFAULT_BIN_PER_POSITION.toNumber() / 2; + + const admin = Keypair.fromSecretKey( + new Uint8Array([ + 230, 207, 238, 109, 95, 154, 47, 93, 183, 250, 147, 189, 87, 15, 117, 184, + 44, 91, 94, 231, 126, 140, 238, 134, 29, 58, 8, 182, 88, 22, 113, 234, 8, + 234, 192, 109, 87, 125, 190, 55, 129, 173, 227, 8, 104, 201, 104, 13, 31, + 178, 74, 80, 54, 14, 77, 78, 226, 57, 47, 122, 166, 165, 57, 144, + ]) + ); + + beforeEach(async () => { + svm = new LiteSVM(); + svm.addProgramFromFile( + new PublicKey(ZapIDL.address), + "./target/deploy/zap.so" + ); + svm.addProgramFromFile( + new PublicKey(DLMM_PROGRAM_ID_LOCAL), + "./tests/fixtures/dlmm.so" + ); + + user = Keypair.generate(); + // admin = Keypair.generate(); + svm.airdrop(user.publicKey, BigInt(LAMPORTS_PER_SOL)); + svm.airdrop(admin.publicKey, BigInt(LAMPORTS_PER_SOL)); + + tokenXMint = createToken(svm, admin, admin.publicKey, null); + tokenYMint = createToken(svm, admin, admin.publicKey, null); + mintToken(svm, admin, tokenXMint, admin, admin.publicKey); + mintToken(svm, admin, tokenYMint, admin, admin.publicKey); + + mintToken(svm, admin, tokenXMint, admin, user.publicKey); + mintToken(svm, admin, tokenYMint, admin, user.publicKey); + + console.log("create lb pair"); + lbPair = await createDlmmPermissionlessPool({ + svm, + creator: admin, + tokenX: tokenXMint, + tokenY: tokenYMint, + activeId, + baseFactor: 10000, + binStep: binStep.toNumber(), + }); + + console.log("Create bin array"); + const binArrayIndex = binIdToBinArrayIndex(activeId); + const binArrayIndexes = []; + + // Lower bin arrays + for (let i = binArrayDelta; i > 0; i--) { + const idx = binArrayIndex.sub(new BN(i)); + binArrayIndexes.push(idx); + } + + binArrayIndexes.push(binArrayIndex); + + // Upper bin arrays + for (let i = 1; i <= binArrayDelta; i++) { + const idx = binArrayIndex.add(new BN(i)); + binArrayIndexes.push(idx); + } + await createBinArrays(svm, admin, lbPair, binArrayIndexes); + + const amount = new BN(1000).mul(new BN(10 ** TOKEN_DECIMALS)); + await dlmmCreatePositionAndAddLiquidityRadius( + svm, + admin, + lbPair, + lowerBinId, + activeId, + tokenXMint, + tokenYMint, + amount, + amount, + new BN(lowerBinId), + new BN(upperBinId) + ); + }); + + it("Zapin dlmm with Spot strategy", async () => { + await initializeBinArrayBitmapExtension(svm, lbPair, admin); + const position = await createDlmmPosition(svm, user, lbPair, lowerBinId); + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + + const binArrays = getBinArrayAccountMetaByBinRange( + lbPair, + new BN(lowerBinId), + new BN(upperBinId) + ); + + await zapInDlmmFullFlow({ + svm, + user, + lbPair, + position, + inputTokenMint: tokenXMint, + outputTokenMint: tokenYMint, + totalAmount: amountTokenA, + amountSwap, + strategy: StrategyType.Spot, + minDeltaId, + maxDeltaId, + binArrays, + remainingAccountInfo: { slices: [] }, + }); + }); + + it("Zapin dlmm with Bidask strategy", async () => { + await initializeBinArrayBitmapExtension(svm, lbPair, admin); + const position = await createDlmmPosition(svm, user, lbPair, lowerBinId); + + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + + const binArrays = getBinArrayAccountMetaByBinRange( + lbPair, + new BN(lowerBinId), + new BN(upperBinId) + ); + + await zapInDlmmFullFlow({ + svm, + user, + lbPair, + position, + inputTokenMint: tokenXMint, + outputTokenMint: tokenYMint, + totalAmount: amountTokenA, + amountSwap, + minDeltaId, + maxDeltaId, + strategy: StrategyType.BidAsk, + binArrays, + remainingAccountInfo: { slices: [] }, + }); + }); + + it("Zapin dlmm with Curve strategy", async () => { + await initializeBinArrayBitmapExtension(svm, lbPair, admin); + const position = await createDlmmPosition(svm, user, lbPair, lowerBinId); + + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + + const binArrays = getBinArrayAccountMetaByBinRange( + lbPair, + new BN(lowerBinId), + new BN(upperBinId) + ); + + await zapInDlmmFullFlow({ + svm, + user, + lbPair, + position, + inputTokenMint: tokenXMint, + outputTokenMint: tokenYMint, + totalAmount: amountTokenA, + amountSwap, + minDeltaId, + maxDeltaId, + strategy: StrategyType.Curve, + binArrays, + remainingAccountInfo: { slices: [] }, + }); + }); + + it("Zapin dlmm single bin with Curve strategy", async () => { + await initializeBinArrayBitmapExtension(svm, lbPair, admin); + const position = await createDlmmPosition(svm, user, lbPair, lowerBinId); + + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + + const binArrays = getBinArrayAccountMetaByBinRange( + lbPair, + new BN(lowerBinId), + new BN(upperBinId) + ); + + await zapInDlmmFullFlow({ + svm, + user, + lbPair, + position, + inputTokenMint: tokenXMint, + outputTokenMint: tokenYMint, + totalAmount: amountTokenA, + amountSwap, + minDeltaId: 0, + maxDeltaId: 0, + strategy: StrategyType.Curve, + binArrays, + remainingAccountInfo: { slices: [] }, + }); + }); + + it("Zapin dlmm single bin with Bid/ask strategy", async () => { + await initializeBinArrayBitmapExtension(svm, lbPair, admin); + const position = await createDlmmPosition(svm, user, lbPair, lowerBinId); + + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + + const binArrays = getBinArrayAccountMetaByBinRange( + lbPair, + new BN(lowerBinId), + new BN(upperBinId) + ); + + await zapInDlmmFullFlow({ + svm, + user, + lbPair, + position, + inputTokenMint: tokenXMint, + outputTokenMint: tokenYMint, + totalAmount: amountTokenA, + amountSwap, + minDeltaId: 0, + maxDeltaId: 0, + strategy: StrategyType.BidAsk, + binArrays, + remainingAccountInfo: { slices: [] }, + }); + }); + + it("Zapin dlmm without bin array bitmap extension", async () => { + const position = await createDlmmPosition(svm, user, lbPair, lowerBinId); + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + + const binArrays = getBinArrayAccountMetaByBinRange( + lbPair, + new BN(lowerBinId), + new BN(upperBinId) + ); + + await zapInDlmmFullFlow({ + svm, + user, + lbPair, + position, + inputTokenMint: tokenXMint, + outputTokenMint: tokenYMint, + totalAmount: amountTokenA, + amountSwap, + strategy: StrategyType.Spot, + minDeltaId, + maxDeltaId, + binArrays, + remainingAccountInfo: { slices: [] }, + }); + }); +}); + +async function zapInDlmmFullFlow(params: { + svm: LiteSVM; + user: Keypair; + lbPair: PublicKey; + position: PublicKey; + inputTokenMint: PublicKey; + outputTokenMint: PublicKey; + totalAmount: BN; + amountSwap: BN; + strategy; + minDeltaId: number; + maxDeltaId: number; + binArrays: AccountMeta[]; + remainingAccountInfo: RemainingAccountsInfo; +}) { + const { + svm, + user, + lbPair, + position, + inputTokenMint, + outputTokenMint, + amountSwap, + totalAmount, + minDeltaId, + maxDeltaId, + strategy, + binArrays, + remainingAccountInfo, + } = params; + + let lbPairState = getLbPairState(svm, lbPair); + const swapForY = inputTokenMint.equals(lbPairState.tokenXMint); + const swapTx = await dlmmSwap( + svm, + user.publicKey, + lbPair, + amountSwap, + swapForY + ); + + const initializeLedgerTx = await initializeLedgerAccount(user.publicKey); + + const setLedgerBalanceTx = await setLedgerBalance( + user.publicKey, + totalAmount.sub(amountSwap), + inputTokenMint.equals(lbPairState.tokenXMint) + ); + + // update balance after swapxww + const tokenBAccount = getAssociatedTokenAddressSync( + outputTokenMint, + user.publicKey + ); + + const preBalance = getTokenBalance(svm, tokenBAccount); + + const updateLedgerBalanceAfterSwapTx = await updateLedgerBalanceAfterSwap( + user.publicKey, + tokenBAccount, + preBalance, + U64_MAX, + outputTokenMint.equals(lbPairState.tokenXMint) + ); + + // zapin + const [binArrayBitmapExtension] = deriveBinArrayBitmapExtension(lbPair); + const zapInTx = await zapInDlmmforInitializedPosition({ + svm, + owner: user.publicKey, + lbPair, + position, + activeId: lbPairState.activeId, + minDeltaId, + maxDeltaId, + maxActiveBinSlippage: 10, + favorXInActiveId: true, + strategy, + remainingAccountInfo, + binArrays, + binArrayBitmapExtension, + }); + + // close ledge + const closeLedgerTx = await closeLedgerAccount(user.publicKey); + + const finalTx = new Transaction() + .add(SET_COMPUTE_UNIT_LIMIT_IX) + .add(swapTx) + .add(initializeLedgerTx) + .add(setLedgerBalanceTx) + .add(updateLedgerBalanceAfterSwapTx) + .add(zapInTx) + .add(closeLedgerTx); + + finalTx.recentBlockhash = svm.latestBlockhash(); + finalTx.sign(user); + + const result = svm.sendTransaction(finalTx); + if (result instanceof FailedTransactionMetadata) { + console.log(result.err()); + console.log(result.meta().logs()); + } else { + // console.log(result.logs()); + } + expect(result).instanceOf(TransactionMetadata); + + let liquidities = getPositionTotalLiquidityAllBin(svm, position); + if (liquidities.length > 1) { + // there is a bug in babar that we could draw single bin + console.log(babar(liquidities)); + } else { + console.log("Liquidity distribution (bin_index, liquidity)"); + console.log(liquidities); + } + +} diff --git a/tests/test_zapin/zapin_dlmm_uninitialize_position.test.ts b/tests/test_zapin/zapin_dlmm_uninitialize_position.test.ts new file mode 100644 index 0000000..5b51080 --- /dev/null +++ b/tests/test_zapin/zapin_dlmm_uninitialize_position.test.ts @@ -0,0 +1,357 @@ +import { + FailedTransactionMetadata, + LiteSVM, + TransactionMetadata, +} from "litesvm"; +import { + PublicKey, + Keypair, + LAMPORTS_PER_SOL, + Transaction, + AccountMeta, +} from "@solana/web3.js"; +import { + createToken, + mintToken, + TOKEN_DECIMALS, + initializeLedgerAccount, + setLedgerBalance, + getTokenBalance, + updateLedgerBalanceAfterSwap, + closeLedgerAccount, + zapInDlmmforUnInitializedPosition, + U64_MAX, +} from "../common"; +import babar from "babar"; +import { expect } from "chai"; + +import ZapIDL from "../../target/idl/zap.json"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; +import { + binIdToBinArrayIndex, + createBinArrays, + DLMM_PROGRAM_ID_LOCAL, + dlmmCreatePositionAndAddLiquidityRadius, + dlmmSwap, + getLbPairState, + getPositionTotalLiquidityAllBin, + DEFAULT_BIN_PER_POSITION, + RemainingAccountsInfo, + StrategyType, + createDlmmPermissionlessPool, + getBinArrayAccountMetaByBinRange, + initializeBinArrayBitmapExtension, +} from "../common/dlmm"; +import { BN } from "@coral-xyz/anchor"; +import { deriveBinArrayBitmapExtension } from "../common/pda"; + +describe("Zapin DLMM with Uninitialize position", () => { + let svm: LiteSVM; + let user: Keypair; + let tokenXMint: PublicKey; + let tokenYMint: PublicKey; + let lbPair: PublicKey; + + const binStep = new BN(10); + const binDelta = 3; + const activeId = new BN(5660); + const lowerBinId = + activeId.toNumber() - DEFAULT_BIN_PER_POSITION.toNumber() / 2; + // 5 = Create 5 lower bin arrays, and 5 upper bin arrays surrounding the active bin arrays. Total bins = 600 * 11 + const binArrayDelta = 5; + const upperBinId = DEFAULT_BIN_PER_POSITION.toNumber() + lowerBinId - 1; + + const admin = Keypair.fromSecretKey( + new Uint8Array([ + 230, 207, 238, 109, 95, 154, 47, 93, 183, 250, 147, 189, 87, 15, 117, 184, + 44, 91, 94, 231, 126, 140, 238, 134, 29, 58, 8, 182, 88, 22, 113, 234, 8, + 234, 192, 109, 87, 125, 190, 55, 129, 173, 227, 8, 104, 201, 104, 13, 31, + 178, 74, 80, 54, 14, 77, 78, 226, 57, 47, 122, 166, 165, 57, 144, + ]) + ); + + beforeEach(async () => { + svm = new LiteSVM(); + svm.addProgramFromFile( + new PublicKey(ZapIDL.address), + "./target/deploy/zap.so" + ); + svm.addProgramFromFile( + new PublicKey(DLMM_PROGRAM_ID_LOCAL), + "./tests/fixtures/dlmm.so" + ); + + user = Keypair.generate(); + // admin = Keypair.generate(); + svm.airdrop(user.publicKey, BigInt(LAMPORTS_PER_SOL)); + svm.airdrop(admin.publicKey, BigInt(LAMPORTS_PER_SOL)); + + tokenXMint = createToken(svm, admin, admin.publicKey, null); + tokenYMint = createToken(svm, admin, admin.publicKey, null); + mintToken(svm, admin, tokenXMint, admin, admin.publicKey); + mintToken(svm, admin, tokenYMint, admin, admin.publicKey); + + mintToken(svm, admin, tokenXMint, admin, user.publicKey); + mintToken(svm, admin, tokenYMint, admin, user.publicKey); + + console.log("create lb pair"); + + lbPair = await createDlmmPermissionlessPool({ + svm, + creator: admin, + tokenX: tokenXMint, + tokenY: tokenYMint, + activeId, + baseFactor: 10000, + binStep: binStep.toNumber(), + }); + + console.log("Create bin array"); + const binArrayIndex = binIdToBinArrayIndex(activeId); + const binArrayIndexes = []; + + // Lower bin arrays + for (let i = binArrayDelta; i > 0; i--) { + const idx = binArrayIndex.sub(new BN(i)); + binArrayIndexes.push(idx); + } + + binArrayIndexes.push(binArrayIndex); + + // Upper bin arrays + for (let i = 1; i <= binArrayDelta; i++) { + const idx = binArrayIndex.add(new BN(i)); + binArrayIndexes.push(idx); + } + await createBinArrays(svm, admin, lbPair, binArrayIndexes); + + const amount = new BN(1000).mul(new BN(10 ** TOKEN_DECIMALS)); + await dlmmCreatePositionAndAddLiquidityRadius( + svm, + admin, + lbPair, + lowerBinId, + activeId, + tokenXMint, + tokenYMint, + amount, + amount, + new BN(lowerBinId), + new BN(upperBinId) + ); + }); + + it("Zapin dlmm with Spot strategy", async () => { + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + + await initializeBinArrayBitmapExtension(svm, lbPair, admin); + + const binArrays = getBinArrayAccountMetaByBinRange( + lbPair, + new BN(lowerBinId), + new BN(upperBinId) + ); + + await zapInDlmmFullFlow({ + svm, + user, + lbPair, + binDelta, + inputTokenMint: tokenXMint, + outputTokenMint: tokenYMint, + totalAmount: amountTokenA, + amountSwap, + strategy: StrategyType.Spot, + binArrays, + remainingAccountInfo: { slices: [] }, + }); + }); + + it("Zapin dlmm with Bidask strategy", async () => { + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + + await initializeBinArrayBitmapExtension(svm, lbPair, admin); + + const binArrays = getBinArrayAccountMetaByBinRange( + lbPair, + new BN(lowerBinId), + new BN(upperBinId) + ); + + await zapInDlmmFullFlow({ + svm, + user, + lbPair, + binDelta, + inputTokenMint: tokenXMint, + outputTokenMint: tokenYMint, + totalAmount: amountTokenA, + amountSwap, + strategy: StrategyType.BidAsk, + binArrays, + remainingAccountInfo: { slices: [] }, + }); + }); + + it("Zapin dlmm with Curve strategy", async () => { + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + + await initializeBinArrayBitmapExtension(svm, lbPair, admin); + + const binArrays = getBinArrayAccountMetaByBinRange( + lbPair, + new BN(lowerBinId), + new BN(upperBinId) + ); + + await zapInDlmmFullFlow({ + svm, + user, + lbPair, + binDelta, + inputTokenMint: tokenXMint, + outputTokenMint: tokenYMint, + totalAmount: amountTokenA, + amountSwap, + strategy: StrategyType.Curve, + binArrays, + remainingAccountInfo: { slices: [] }, + }); + }); + + it("Zapin dlmm without binArraybitmapExtension", async () => { + const amountTokenA = new BN(LAMPORTS_PER_SOL); + const amountSwap = amountTokenA.divn(2); + + const binArrays = getBinArrayAccountMetaByBinRange( + lbPair, + new BN(lowerBinId), + new BN(upperBinId) + ); + + await zapInDlmmFullFlow({ + svm, + user, + lbPair, + binDelta, + inputTokenMint: tokenXMint, + outputTokenMint: tokenYMint, + totalAmount: amountTokenA, + amountSwap, + strategy: StrategyType.Spot, + binArrays, + remainingAccountInfo: { slices: [] }, + }); + }); +}); + +async function zapInDlmmFullFlow(params: { + svm: LiteSVM; + user: Keypair; + lbPair: PublicKey; + inputTokenMint: PublicKey; + outputTokenMint: PublicKey; + binDelta: number; + totalAmount: BN; + amountSwap: BN; + strategy; + binArrays: AccountMeta[]; + remainingAccountInfo: RemainingAccountsInfo; +}) { + const { + svm, + user, + lbPair, + binDelta, + inputTokenMint, + outputTokenMint, + amountSwap, + totalAmount, + strategy, + remainingAccountInfo, + binArrays, + } = params; + + let lbPairState = getLbPairState(svm, lbPair); + const swapForY = inputTokenMint.equals(lbPairState.tokenXMint); + const swapTx = await dlmmSwap( + svm, + user.publicKey, + lbPair, + amountSwap, + swapForY + ); + + const initializeLedgerTx = await initializeLedgerAccount(user.publicKey); + + const setLedgerBalanceTx = await setLedgerBalance( + user.publicKey, + totalAmount.sub(amountSwap), + inputTokenMint.equals(lbPairState.tokenXMint) + ); + + // update balance after swapxww + const tokenBAccount = getAssociatedTokenAddressSync( + outputTokenMint, + user.publicKey + ); + + const preBalance = getTokenBalance(svm, tokenBAccount); + + const updateLedgerBalanceAfterSwapTx = await updateLedgerBalanceAfterSwap( + user.publicKey, + tokenBAccount, + preBalance, + U64_MAX, + outputTokenMint.equals(lbPairState.tokenXMint) + ); + + // zapin + const [binArrayBitmapExtension] = deriveBinArrayBitmapExtension(lbPair); + + const positionKP = Keypair.generate(); + + const zapInTx = await zapInDlmmforUnInitializedPosition({ + svm, + owner: user.publicKey, + lbPair, + position: positionKP.publicKey, + activeId: lbPairState.activeId, + minDeltaId: -binDelta, + maxDeltaId: binDelta, + maxActiveBinSlippage: 10, + favorXInActiveId: true, + strategy, + remainingAccountInfo, + binArrays, + binArrayBitmapExtension, + }); + + // close ledge + const closeLedgerTx = await closeLedgerAccount(user.publicKey); + + const finalTx = new Transaction() + .add(swapTx) + .add(initializeLedgerTx) + .add(setLedgerBalanceTx) + .add(updateLedgerBalanceAfterSwapTx) + .add(zapInTx) + .add(closeLedgerTx); + + finalTx.recentBlockhash = svm.latestBlockhash(); + finalTx.sign(user, positionKP); + + const result = svm.sendTransaction(finalTx); + if (result instanceof FailedTransactionMetadata) { + console.log(result.meta().logs()); + } else { + // console.log(result.logs()); + } + expect(result).instanceOf(TransactionMetadata); + + let liquidities = getPositionTotalLiquidityAllBin(svm, positionKP.publicKey); + console.log(babar(liquidities)); +} diff --git a/tests/zap_out_damm_v2.test.ts b/tests/test_zapout/zap_out_damm_v2.test.ts similarity index 88% rename from tests/zap_out_damm_v2.test.ts rename to tests/test_zapout/zap_out_damm_v2.test.ts index 0062b24..a6155c2 100644 --- a/tests/zap_out_damm_v2.test.ts +++ b/tests/test_zapout/zap_out_damm_v2.test.ts @@ -1,4 +1,8 @@ -import { LiteSVM, TransactionMetadata } from "litesvm"; +import { + FailedTransactionMetadata, + LiteSVM, + TransactionMetadata, +} from "litesvm"; import { PublicKey, Keypair, @@ -11,20 +15,18 @@ import { mintToken, ZapProgram, zapOutDammv2, -} from "./common"; +} from "../common"; import { TOKEN_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token"; import { expect } from "chai"; -import ZapIDL from "../target/idl/zap.json"; -import DAMMV2IDL from "../idls/damm_v2.json"; +import ZapIDL from "../../target/idl/zap.json"; +import DAMMV2IDL from "../../idls/damm_v2.json"; import { createDammV2Pool, createPositionAndAddLiquidity, removeLiquidity, -} from "./common/damm_v2"; -import { - getAssociatedTokenAddressSync -} from "@solana/spl-token"; +} from "../common/damm_v2"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; describe("Zap out damm V2", () => { let zapProgram: ZapProgram; @@ -101,9 +103,7 @@ describe("Zap out damm V2", () => { finalTransaction.sign(user); const result = svm.sendTransaction(finalTransaction); - if (result instanceof TransactionMetadata) { - console.log(result.logs()); - } else { + if (result instanceof FailedTransactionMetadata) { console.log(result.meta().logs()); } expect(result).instanceOf(TransactionMetadata); diff --git a/tests/zap_out_dlmm.test.ts b/tests/test_zapout/zap_out_dlmm.test.ts similarity index 84% rename from tests/zap_out_dlmm.test.ts rename to tests/test_zapout/zap_out_dlmm.test.ts index 4c2d5e0..b5acb64 100644 --- a/tests/zap_out_dlmm.test.ts +++ b/tests/test_zapout/zap_out_dlmm.test.ts @@ -1,4 +1,8 @@ -import { LiteSVM, TransactionMetadata } from "litesvm"; +import { + FailedTransactionMetadata, + LiteSVM, + TransactionMetadata, +} from "litesvm"; import { PublicKey, Keypair, @@ -12,11 +16,12 @@ import { ZapProgram, zapOutDlmm, TOKEN_DECIMALS, -} from "./common"; + warpSlotBy, +} from "../common"; import { TOKEN_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token"; import { expect } from "chai"; -import ZapIDL from "../target/idl/zap.json"; +import ZapIDL from "../../target/idl/zap.json"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { binIdToBinArrayIndex, @@ -25,9 +30,10 @@ import { createPresetParameter2, DLMM_PROGRAM_ID_LOCAL, dlmmCreatePositionAndAddLiquidityRadius, - MAX_BIN_PER_POSITION, + DEFAULT_BIN_PER_POSITION, removeAllLiquidity, -} from "./common/dlmm"; + createDlmmPermissionlessPool, +} from "../common/dlmm"; import { BN } from "@coral-xyz/anchor"; describe("Zap out dlmm", () => { @@ -40,10 +46,11 @@ describe("Zap out dlmm", () => { const binStep = new BN(10); const activeId = new BN(5660); - const lowerBinId = activeId.toNumber() - MAX_BIN_PER_POSITION.toNumber() / 2; + const lowerBinId = + activeId.toNumber() - DEFAULT_BIN_PER_POSITION.toNumber() / 2; // 5 = Create 5 lower bin arrays, and 5 upper bin arrays surrounding the active bin arrays. Total bins = 600 * 11 const binArrayDelta = 5; - const upperBinId = MAX_BIN_PER_POSITION.toNumber() + lowerBinId - 1; + const upperBinId = DEFAULT_BIN_PER_POSITION.toNumber() + lowerBinId - 1; const admin = Keypair.fromSecretKey( new Uint8Array([ @@ -79,33 +86,17 @@ describe("Zap out dlmm", () => { mintToken(svm, admin, tokenAMint, admin, user.publicKey); mintToken(svm, admin, tokenBMint, admin, user.publicKey); - console.log("create presetParameter2"); - let presetParameter2 = await createPresetParameter2( - svm, - admin, - new BN(0), - binStep.toNumber(), - 10000, - 0, - 0, - 0, - 0, - 0, - 500, - 0 - ); - console.log("create lb pair"); - lbPair = await createDlmmPool( + lbPair = await createDlmmPermissionlessPool({ svm, - admin, - tokenAMint, - tokenBMint, + creator: admin, + tokenX: tokenAMint, + tokenY: tokenBMint, activeId, - TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, - presetParameter2 - ); + baseFactor: 10000, + binStep: binStep.toNumber(), + }); + warpSlotBy(svm, new BN(1)); console.log("Create bin array"); const binArrayIndex = binIdToBinArrayIndex(activeId); @@ -203,9 +194,7 @@ describe("Zap out dlmm", () => { finalTransaction.sign(user); const result = svm.sendTransaction(finalTransaction); - if (result instanceof TransactionMetadata) { - console.log(result.logs()); - } else { + if (result instanceof FailedTransactionMetadata) { console.log(result.meta().logs()); } expect(result).instanceOf(TransactionMetadata); diff --git a/tests/zap_out_dlmm_transfer_hook.test.ts b/tests/test_zapout/zap_out_dlmm_transfer_hook.test.ts similarity index 86% rename from tests/zap_out_dlmm_transfer_hook.test.ts rename to tests/test_zapout/zap_out_dlmm_transfer_hook.test.ts index 1089d9c..6f0b3d6 100644 --- a/tests/zap_out_dlmm_transfer_hook.test.ts +++ b/tests/test_zapout/zap_out_dlmm_transfer_hook.test.ts @@ -1,4 +1,8 @@ -import { LiteSVM, TransactionMetadata } from "litesvm"; +import { + FailedTransactionMetadata, + LiteSVM, + TransactionMetadata, +} from "litesvm"; import { PublicKey, Keypair, @@ -11,11 +15,12 @@ import { zapOutDlmm, TOKEN_DECIMALS, createTokenWithTransferHook, -} from "./common"; + warpSlotBy, +} from "../common"; import { TOKEN_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token"; import { expect } from "chai"; -import ZapIDL from "../target/idl/zap.json"; +import ZapIDL from "../../target/idl/zap.json"; import { getAssociatedTokenAddressSync, TOKEN_2022_PROGRAM_ID, @@ -28,14 +33,15 @@ import { DLMM_PROGRAM_ID_LOCAL, dlmmCreatePositionAndAddLiquidityRadius, initializeTokenBadge, - MAX_BIN_PER_POSITION, + DEFAULT_BIN_PER_POSITION, removeAllLiquidity, -} from "./common/dlmm"; + createDlmmPermissionlessPool, +} from "../common/dlmm"; import { BN } from "@coral-xyz/anchor"; import { createExtraAccountMetaListAndCounter, TRANSFER_HOOK_COUNTER_PROGRAM_ID, -} from "./common/transferHook"; +} from "../common/transferHook"; describe("Zap out dlmm with transfer hook", () => { let svm: LiteSVM; @@ -48,9 +54,10 @@ describe("Zap out dlmm with transfer hook", () => { const activeId = new BN(5660); // 5 = Create 5 lower bin arrays, and 5 upper bin arrays surrounding the active bin arrays. Total bins = 600 * 11 const binArrayDelta = 5; - const lowerBinId = activeId.toNumber() - MAX_BIN_PER_POSITION.toNumber() / 2; + const lowerBinId = + activeId.toNumber() - DEFAULT_BIN_PER_POSITION.toNumber() / 2; - const upperBinId = MAX_BIN_PER_POSITION.toNumber() + lowerBinId - 1; + const upperBinId = DEFAULT_BIN_PER_POSITION.toNumber() + lowerBinId - 1; const admin = Keypair.fromSecretKey( new Uint8Array([ @@ -112,35 +119,21 @@ describe("Zap out dlmm with transfer hook", () => { mintToken(svm, admin, tokenBMint, admin, user.publicKey); console.log("create presetParameter2"); - let presetParameter2 = await createPresetParameter2( - svm, - admin, - new BN(0), - binStep.toNumber(), - 10000, - 0, - 0, - 0, - 0, - 0, - 500, - 0 - ); - console.log("create token badge"); await initializeTokenBadge(svm, admin, tokenAMint); console.log("create lb pair"); - lbPair = await createDlmmPool( + lbPair = await createDlmmPermissionlessPool({ svm, - admin, - tokenAMint, - tokenBMint, + creator: admin, + tokenX: tokenAMint, + tokenY: tokenBMint, activeId, - TOKEN_2022_PROGRAM_ID, - TOKEN_PROGRAM_ID, - presetParameter2 - ); + baseFactor: 10000, + binStep: binStep.toNumber(), + }); + + warpSlotBy(svm, new BN(1)); console.log("Create bin array"); const binArrayIndex = binIdToBinArrayIndex(activeId); @@ -243,9 +236,7 @@ describe("Zap out dlmm with transfer hook", () => { finalTransaction.sign(user); const result = svm.sendTransaction(finalTransaction); - if (result instanceof TransactionMetadata) { - console.log(result.logs()); - } else { + if (result instanceof FailedTransactionMetadata) { console.log(result.meta().logs()); } expect(result).instanceOf(TransactionMetadata); diff --git a/tests/zap_out_jup_v6.test.ts b/tests/test_zapout/zap_out_jup_v6.test.ts similarity index 82% rename from tests/zap_out_jup_v6.test.ts rename to tests/test_zapout/zap_out_jup_v6.test.ts index 70df28b..d57b1e3 100644 --- a/tests/zap_out_jup_v6.test.ts +++ b/tests/test_zapout/zap_out_jup_v6.test.ts @@ -1,4 +1,8 @@ -import { LiteSVM, TransactionMetadata } from "litesvm"; +import { + FailedTransactionMetadata, + LiteSVM, + TransactionMetadata, +} from "litesvm"; import { PublicKey, Keypair, @@ -11,21 +15,19 @@ import { mintToken, ZapProgram, zapOutJupV6, -} from "./common"; +} from "../common"; import { TOKEN_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token"; import { expect } from "chai"; -import ZapIDL from "../target/idl/zap.json"; +import ZapIDL from "../../target/idl/zap.json"; import { createDammV2Pool, createPositionAndAddLiquidity, DAMM_V2_PROGRAM_ID, removeLiquidity, -} from "./common/damm_v2"; -import { - getAssociatedTokenAddressSync -} from "@solana/spl-token"; -import { JUP_V6_PROGRAM_ID } from "./common/jup"; +} from "../common/damm_v2"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; +import { JUP_V6_PROGRAM_ID } from "../common/jup"; describe("Zap out Jup V6", () => { let zapProgram: ZapProgram; @@ -43,14 +45,8 @@ describe("Zap out Jup V6", () => { new PublicKey(ZapIDL.address), "./target/deploy/zap.so" ); - svm.addProgramFromFile( - DAMM_V2_PROGRAM_ID, - "./tests/fixtures/damm_v2.so" - ); - svm.addProgramFromFile( - JUP_V6_PROGRAM_ID, - "./tests/fixtures/jup_v6.so" - ); + svm.addProgramFromFile(DAMM_V2_PROGRAM_ID, "./tests/fixtures/damm_v2.so"); + svm.addProgramFromFile(JUP_V6_PROGRAM_ID, "./tests/fixtures/jup_v6.so"); user = Keypair.generate(); admin = Keypair.generate(); @@ -106,9 +102,7 @@ describe("Zap out Jup V6", () => { finalTransaction.sign(user); const result = svm.sendTransaction(finalTransaction); - if (result instanceof TransactionMetadata) { - console.log(result.logs()); - } else { + if (result instanceof FailedTransactionMetadata) { console.log(result.meta().logs()); } expect(result).instanceOf(TransactionMetadata);